Old PS Bug Carried Over? Add shop address to header in PDF invoice



  • After copying the shop data over from PS 1.6 to TB 103 via MigrationPro module, the pdf invoices do not have the shop address in the header.

    I found this fix but do not know how to follow the directions. Do I edit both files before putting the copy in /override/classes/pdf, or do I put the copy in before editing?

    Not even sure the directions will work but posted it here in case it needs a permanent fix in TB.

    Can someone please help me out. I have an invoice I have to print but it does not have the shop address in the header.

    This is the code from:
    http://angelwings.net/blog/prestashop-1-6-add-shop-address-to-header-in-pdf-invoice/

    Prestashop 1.6: Add shop address to header in PDF invoice
    Posted on May 18, 2016 by admin
    IMPORTANT NOTE*
    ISSUE: Shop address at the top of current customised PDF invoice doesn’t seem to be updated when address is changed to a new one via Backoffice.
    The order invoice’s shop address data is added to the database (TABLE: ps_order_invoice) upon creation under the “shop_address” field.
    Changing the following will not update old invoice entries

    1. Backoffice, Preferences > Store Contacts or
    2. Modules Custom Contact Page (Warehouse)
      It will only affect new invoice entries.

    When using the same code in the footer.tpl on header.tpl, the shop address doesn’t show up. This is because the header function that loads the header data doesn’t contain the code to retrieve the shop address. The following will add the code to do so.

    1. Copy /classes/pdf/HTMLTemplate.php (and put the copy in /override/classes/pdf)

    go to public function assignCommonHeaderData()

    Under $shop_name = Configuration::get(‘PS_SHOP_NAME’, null, null, $id_shop);

    Add

    $shop_address = $this->getShopAddress();

    Next, under ‘shop_name’ => $shop_name,

    Add

    ‘shop_address’ => $shop_address,

    1. Open /pdf/header.tpl

    Remove {$shop_name|escape:’html’:’UTF-8′}

    Add {$shop_address|escape:’html’:’UTF-8′}

    Adjust css styles as required.



  • Are you sure that your /classes and /controllers folders both fresh 1.0.3 files?



  • Sure. I installed TB with Softaculous on a brand new host. I then imported customers, orders, categories, products etc; into TB with Prestashop MigrationPro. I don’t think PS MigrationPro would have changed any classes/ controllers folders but I could be wrong.

    I did add the shop address that was missing from the ‘Contact information block v2.0.0 - by thirty bees’ module, and I can’t remember if it was enabled or not but it is enabled now. I am using the Warehouse Theme ‘Contacts’ module which had the correct address. After adding the address to the 'Contact information block v2.0.0 - by thirty bees" module and clearing the cache, the address appeared at the footer of the Invoice but not in the header. Maybe I need a new order to see if adding the address will appear in the header in a new order invoice?



  • I just did some testing myself, and found out a few things. Like you were saying, or the blog you posted, if you change your address on the site, you’re old invoices won’t have the new address on them, they will have the address at the time when they were created. So, I changed my address, looked at some old invoices, my addy wasn’t on them. I made a new order, and my address was on that invoice. So… I dunno what to tell ya, I guess you could do what that blog suggested, modifying those files.



  • Thanks… I do not need to change the address on the invoices from the old shop, just the new invoices going forward. Hopefully all that was needed was the address change in the TB Contact module. Will find out when the next order comes in.



  • Actually I think it gets its address info from BO>Preferences>Store Contacts then Contact Details at the bottom of the page.



  • Hmmm… That was already filled in. I’m hoping the TB Contacts module was the problem. Waiting for another order to see if the address is in the header. My first two orders came in together and I did not notice the address problem. I just printed the invoices and sent them off. It was only this third order that I noticed the address was not in the header or footer. Enabling and filling in the TB Contacts module got the address on the footer of that invoice, so I am hoping the address will be on the header and footer on the next fresh invoice,



  • Is your website setup to be mutlistore?



  • No, thank heavens!



  • I’m 99% sure then that the pdfs get their address info from BO>Preferences>Store Contacts.



  • Yey… an order just came in and the invoice has the shop address in the invoice header and footer like it should be. NO OLD PS BUGS CARRIED OVER! …and no having to mess with core codes.



  • Awesome, that is great.


 

Looks like your connection to thirty bees forum was lost, please wait while we try to reconnect.