Jump to content

Add Manufacturer name / image on invoices


Recommended Posts

Hi,

 

I need to show manufacturer (brand in my case) on invoices.

And as a bonus, UPC product code :)

I have my .tpl in the theme (pdf folder) so no problem with Prestashop upgrade.

I am ok with html / css... but php / smarty I am not familiar with.

 

I have tried with {$img_manu_dir}, but that does not seem to be working to retrieve manufacturer images.

 

Any ideas ?

 

I am on the latest version of Prestashop (1.6)

 

Best regards,

 

Quentin

Link to comment
Share on other sites

You should have {$order_detail.id_manufacturer} data available in the template. Try something like:

{Manufacturer::getNameById($order_detail.id_manufacturer)}

Note: the code is not tested and can be completely wrong

Link to comment
Share on other sites

Hi,

 

This works to show the name of the manufacturer, so this is cool, thanks.

Is there a way to show the logo (image linked to the manufacturer in BO), instead of name?

 

Best regards,

 

Quentin

Link to comment
Share on other sites

This seems to retrieve the image, at least create the right URL (PS 1.6) :

<img src="{$img_ps_dir}m/{$order_detail.id_manufacturer}.jpg" style="vertical-align:middle"/>

But then I have :

TCPDF ERROR: [image] Unable to get image: {image URL}

 

Any ideas where this comes from? I read about php configuration, but has the url works, why does it can't get the image?

 

Best regards,

Quentin
 

Link to comment
Share on other sites

  • 2 weeks later...

This seems to retrieve the image, at least create the right URL (PS 1.6) :

<img src="{$img_ps_dir}m/{$order_detail.id_manufacturer}.jpg" style="vertical-align:middle"/>

But then I have :

TCPDF ERROR: [image] Unable to get image: {image URL}

 

Any ideas where this comes from? I read about php configuration, but has the url works, why does it can't get the image?

 

Best regards,

Quentin

 

 

The reason why u getting the error is because you did not assign manufacturer to all products in the order you trying to render the invoice so once the foreach found one product without manufacturer (ID) the value is then zero and 0.jpg does not exist in the m folder this why TCPDF class shows the error. The solution is to put there condition when the manufacturer ID exist for the product then show the image if not do nothing.

 

this code should work for you:

{if $order_detail.id_manufacturer}<img src="{$img_ps_dir}m/{$order_detail.id_manufacturer}.jpg" style="vertical-align:middle"/>{/if}
Edited by UniqueModules (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...