Jump to content

[1.5] How to add product reference number to PDF invoice


Recommended Posts

  • 1 month later...

The only solution is to buy a 99 €module??? Don't think that... We only need to add the reference number near the product name... I see that in /pdf/invoice.tpl at row 129 there is

 

<td style="text-align: left; width: 45%">{$order_detail.product_name}</td>

 

Here we have to insert also the reference... but I don't know wich is the name of the variable and I don't know how to add it with smarty.... please, any help? Thank you very much!

Regars.

Link to comment
Share on other sites

Try

{$order_detail.product_price}

or

{$order_detail.original_product_price}

or

{$order_detail.total_price_tax_incl}

or

{$order_detail.total_price_tax_excl}

or

{$order_detail.unit_price_tax_incl}

or

{$order_detail.unit_price_tax_excl}

Link to comment
Share on other sites

{$order_detail.product_price}

{$order_detail.original_product_price}

{$order_detail.total_price_tax_incl}

{$order_detail.total_price_tax_excl}

{$order_detail.unit_price_tax_incl}

{$order_detail.unit_price_tax_excl}

 

@tuk66 - I have tried them all - they give somehow the information available in the ps_order_detail table - these are not the product "price" field from the ps_product table.

 

Why?

 

Because I use that price to indicate the after-tax-suggested-retail-price, I then set specific prices for special groups (retail shops). When a shop buys something, the price that gets put into the order_detail is the specific price.

 

Shops want to see the MSRP *and* their unit_price

 

thanks if you can help - no worries if it is too much work

Link to comment
Share on other sites

Honestly, I have a very little experience with PrestaShop v1.5 invoice templates system.

 

Oh, how sad for me ... my system as follows:

Server information:

Linux #1 SMP Mon Aug 23 11:13:12 CEST 2010 i686

Server software version: Apache

PHP version: 5.2.17

Memory limit: 128M

Max execution time: 10

Database information

MySQL version: 5.5.27-log

MySQL engine: InnoDB

Tables prefix: ps_

Store information

Prestashop version: 1.5.2.0

 

 

I just tried your demo's - they have a lot of functionality - wish it were a 1.5.2 demo :-(

 

 

thanks for trying to help - is there an easy way to call the data directly from the database ?

Link to comment
Share on other sites

How can i get the product image to show to?

i treid

<td style="text-align: left; width: 45%">{$order_detail.product_img}{$order_detail.product_name} / {$order_detail.reference}</td>

and

<td style="text-align: left; width: 45%">{$order_detail.product_image}{$order_detail.product_name} / {$order_detail.reference}</td>

Both wont work

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...
  • 4 months later...

Just to summarize for everyone... since not everyone may know which template to modify, you need to go under your base root of your prestashop installation directory and there is a folder called "pdf" which has a file called "invoice.tpl"

 

My 1.5.4 version had the following code on line 128 (yours may vary so look for this line):

 

<td style="text-align: left; width: 45%">{$order_detail.product_name}</td>

 

Then replace with:

<td style="text-align: left; width: 45%">{$order_detail.product_name} / {$order_detail.reference}</td>

 

 

 

On another note: I had an issue with a long invoice that would go to a second page and that caused an error in the pdf. So instead I actually changed product reference to come first then product name and i separated them out into different columns. To make life easy I'll just copy my invoice.tpl file here for you to copy into invoice.tpl. Hopefully this helps someone else.

 

{*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2013 PrestaShop SA
*  @license	http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
<div style="font-size: 8pt; color: #444">[/color]
[color="#000088"]<table>
<tr><td> </td></tr>
</table>[/color]
[color="#000088"]<!-- ADDRESSES -->
<table style="width: 100%">
<tr>
 <td style="width: 15%"></td>
 <td style="width: 85%">
  {if !empty($delivery_address)}
<table style="width: 100%">
 <tr>
  <td style="width: 50%">
   <span style="font-weight: bold; font-size: 10pt; color: #9E9F9E">{l s='Delivery Address' pdf='true'}</span><br />
	{$delivery_address}
  </td>
  <td style="width: 50%">
   <span style="font-weight: bold; font-size: 10pt; color: #9E9F9E">{l s='Billing Address' pdf='true'}</span><br />
	{$invoice_address}
  </td>
 </tr>
</table>
  {else}
<table style="width: 100%">
 <tr>[/color]
[color="#000088"]	  <td style="width: 50%">
   <span style="font-weight: bold; font-size: 10pt; color: #9E9F9E">{l s='Billing & Delivery Address.' pdf='true'}</span><br />
	{$invoice_address}
  </td>
  <td style="width: 50%">[/color]
[color="#000088"]	  </td>
 </tr>
</table>
  {/if}
 </td>
</tr>
</table>
<!-- / ADDRESSES -->[/color]
[color="#000088"]<div style="line-height: 1pt"> </div>[/color]
[color="#000088"]<!-- PRODUCTS TAB -->
<table style="width: 100%">
<tr>
 <td style="width: 15%; padding-right: 7px; text-align: right; vertical-align: top; font-size: 7pt;">
  <!-- CUSTOMER INFORMATION -->
  <b>{l s='Order Number:' pdf='true'}</b><br />
  {$order->getUniqReference()}<br />
  <br />
  <b>{l s='Order Date:' pdf='true'}</b><br />
  {dateFormat date=$order->date_add full=0}<br />
  <br />
  <b>{l s='Payment Method:' pdf='true'}</b><br />
  <table style="width: 100%;">
  {foreach from=$order_invoice->getOrderPaymentCollection() item=payment}
<tr>
 <td style="width: 50%">{$payment->payment_method}</td>
 <td style="width: 50%">{displayPrice price=$payment->amount currency=$order->id_currency}</td>
</tr>
  {foreachelse}
<tr>
 <td>{l s='No payment' pdf='true'}</td>
</tr>
  {/foreach}
  </table>
  <br />
  <!-- / CUSTOMER INFORMATION -->
 </td>
 <td style="width: 85%; text-align: right">
  <table style="width: 100%; font-size: 8pt;">
<tr style="line-height:4px;">
 <td style="text-align: left; background-color: #4D4D4D; color: #FFF; padding-left: 10px; font-weight: bold; width: 15%">{l s='Reference' pdf='true'}</td>
 <td style="text-align: left; background-color: #4D4D4D; color: #FFF; padding-left: 10px; font-weight: bold; width: 30%">{l s='Product' pdf='true'}</td>
 <!-- unit price tax excluded is mandatory -->
 {if !$tax_excluded_display}
  <td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold; width: 10%">{l s='Unit Price' pdf='true'} <br />{l s='(Tax Excl.)' pdf='true'}</td>
 {/if}
 <td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold; width: 10%">
  {l s='Unit Price' pdf='true'}
  {if $tax_excluded_display}
	{l s='(Tax Excl.)' pdf='true'}
  {else}
	{l s='(Tax Incl.)' pdf='true'}
  {/if}
 </td>
 <td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold; width: 10%">{l s='Discount' pdf='true'}</td>
 <td style="background-color: #4D4D4D; color: #FFF; text-align: center; font-weight: bold; width: 10%">{l s='Qty' pdf='true'}</td>
 <td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold; width: {if !$tax_excluded_display}15%{else}25%{/if}">
  {l s='Total' pdf='true'}
  {if $tax_excluded_display}
   {l s='(Tax Excl.)' pdf='true'}
  {else}
   {l s='(Tax Incl.)' pdf='true'}
  {/if}
 </td>
</tr>
<!-- PRODUCTS -->
{foreach $order_details as $order_detail}
{cycle values='#FFF,#DDD' assign=bgcolor}
<tr style="line-height:6px;background-color:{$bgcolor};">
 <td style="text-align: left; width: 15%">{$order_detail.reference}</td>
 <td style="text-align: left; width: 30%">{$order_detail.product_name}</td>
 <!-- unit price tax excluded is mandatory -->
 {if !$tax_excluded_display}
  <td style="text-align: right; width: 10%">
  {displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_excl}
  </td>
 {/if}
 <td style="text-align: right; width: 10%">
 {if $tax_excluded_display}
  {displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_excl}
 {else}
  {displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_incl}
 {/if}
 </td>
 <td style="text-align: right; width: 10%">
 {if (isset($order_detail.reduction_amount) && $order_detail.reduction_amount > 0)}
  -{displayPrice currency=$order->id_currency price=$order_detail.reduction_amount}
 {else if (isset($order_detail.reduction_percent) && $order_detail.reduction_percent > 0)}
  -{$order_detail.reduction_percent}%
 {else}
 --
 {/if}
 </td>
 <td style="text-align: center; width: 10%">{$order_detail.product_quantity}</td>
 <td style="width: 15%; text-align: right;  width: {if !$tax_excluded_display}15%{else}25%{/if}">
 {if $tax_excluded_display}
  {displayPrice currency=$order->id_currency price=$order_detail.total_price_tax_excl}
 {else}
  {displayPrice currency=$order->id_currency price=$order_detail.total_price_tax_incl}
 {/if}
 </td>
</tr>
 {foreach $order_detail.customizedDatas as $customizationPerAddress}
  {foreach $customizationPerAddress as $customizationId => $customization}
   <tr style="line-height:6px;background-color:{$bgcolor}; ">
	<td style="line-height:3px; text-align: left; width: 60%; vertical-align: top">[/color]
[color="#000088"]		  <blockquote>
	   {if isset($customization.datas[$smarty.const._CUSTOMIZE_TEXTFIELD_]) && count($customization.datas[$smarty.const._CUSTOMIZE_TEXTFIELD_]) > 0}
		{foreach $customization.datas[$smarty.const._CUSTOMIZE_TEXTFIELD_] as $customization_infos}
		 {$customization_infos.name}: {$customization_infos.value}
		 {if !$smarty.foreach.custo_foreach.last}<br />
		 {else}
		 <div style="line-height:0.4pt"> </div>
		 {/if}
		{/foreach}
	   {/if}[/color]
[color="#000088"]		   {if isset($customization.datas[$smarty.const._CUSTOMIZE_FILE_]) && count($customization.datas[$smarty.const._CUSTOMIZE_FILE_]) > 0}
		{count($customization.datas[$smarty.const._CUSTOMIZE_FILE_])} {l s='image(s)' pdf='true'}
	   {/if}
	  </blockquote>
	</td>
	<td style="text-align: right; width: 15%"></td>
	<td style="text-align: center; width: 10%; vertical-align: top">({$customization.quantity})</td>
	<td style="width: 15%; text-align: right;"></td>
   </tr>
  {/foreach}
 {/foreach}
{/foreach}
<!-- END PRODUCTS -->[/color]
[color="#000088"]	<!-- CART RULES -->
{assign var="shipping_discount_tax_incl" value="0"}
{foreach $cart_rules as $cart_rule}
 {if $cart_rule.free_shipping}
  {assign var="shipping_discount_tax_incl" value=$order_invoice->total_shipping_tax_incl}
 {/if}
 {cycle values='#FFF,#DDD' assign=bgcolor}
 <tr style="line-height:6px;background-color:{$bgcolor}" text-align="left">
  <td style="line-height:3px;text-align:left;width:60%;vertical-align:top" colspan="{if !$tax_excluded_display}5{else}4{/if}">{$cart_rule.name}</td>
  <td>
   {if $tax_excluded_display}
	- {$cart_rule.value_tax_excl}
   {else}
	- {$cart_rule.value}
   {/if}
  </td>
 </tr>
{/foreach}
<!-- END CART RULES -->
  </table>[/color]
[color="#000088"]   <table style="width: 100%">
{if (($order_invoice->total_paid_tax_incl - $order_invoice->total_paid_tax_excl) > 0)}
<tr style="line-height:5px;">
 <td style="width: 85%; text-align: right; font-weight: bold">{l s='Product Total (Tax Excl.)' pdf='true'}</td>
 <td style="width: 15%; text-align: right;">{displayPrice currency=$order->id_currency price=$order_invoice->total_products}</td>
</tr>[/color]
[color="#000088"]	<tr style="line-height:5px;">
 <td style="width: 85%; text-align: right; font-weight: bold">{l s='Product Total (Tax Incl.)' pdf='true'}</td>
 <td style="width: 15%; text-align: right;">{displayPrice currency=$order->id_currency price=$order_invoice->total_products_wt}</td>
</tr>
{else}
<tr style="line-height:5px;">
 <td style="width: 85%; text-align: right; font-weight: bold">{l s='Product Total' pdf='true'}</td>
 <td style="width: 15%; text-align: right;">{displayPrice currency=$order->id_currency price=$order_invoice->total_products}</td>
</tr>
{/if}[/color]
[color="#000088"]	{if $order_invoice->total_discount_tax_incl > 0}
<tr style="line-height:5px;">
 <td style="text-align: right; font-weight: bold">{l s='Total Vouchers' pdf='true'}</td>
 <td style="width: 15%; text-align: right;">-{displayPrice currency=$order->id_currency price=($order_invoice->total_discount_tax_incl + $shipping_discount_tax_incl)}</td>
</tr>
{/if}[/color]
[color="#000088"]	{if $order_invoice->total_wrapping_tax_incl > 0}
<tr style="line-height:5px;">
 <td style="text-align: right; font-weight: bold">{l s='Wrapping Cost' pdf='true'}</td>
 <td style="width: 15%; text-align: right;">
 {if $tax_excluded_display}
  {displayPrice currency=$order->id_currency price=$order_invoice->total_wrapping_tax_excl}
 {else}
  {displayPrice currency=$order->id_currency price=$order_invoice->total_wrapping_tax_incl}
 {/if}
 </td>
</tr>
{/if}[/color]
[color="#000088"]	{if $order_invoice->total_shipping_tax_incl > 0}
<tr style="line-height:5px;">
 <td style="text-align: right; font-weight: bold">{l s='Shipping Cost' pdf='true'}</td>
 <td style="width: 15%; text-align: right;">
  {if $tax_excluded_display}
   {displayPrice currency=$order->id_currency price=$order_invoice->total_shipping_tax_excl}
   {else}
   {displayPrice currency=$order->id_currency price=$order_invoice->total_shipping_tax_incl}
  {/if}
 </td>
</tr>
{/if}[/color]
[color="#000088"]	{if ($order_invoice->total_paid_tax_incl - $order_invoice->total_paid_tax_excl) > 0}
<tr style="line-height:5px;">
 <td style="text-align: right; font-weight: bold">{l s='Total Tax' pdf='true'}</td>
 <td style="width: 15%; text-align: right;">{displayPrice currency=$order->id_currency price=($order_invoice->total_paid_tax_incl - $order_invoice->total_paid_tax_excl)}</td>
</tr>
{/if}[/color]
[color="#000088"]	<tr style="line-height:5px;">
 <td style="text-align: right; font-weight: bold">{l s='Total' pdf='true'}</td>
 <td style="width: 15%; text-align: right;">{displayPrice currency=$order->id_currency price=$order_invoice->total_paid_tax_incl}</td>
</tr>[/color]
[color="#000088"]   </table>[/color]
[color="#000088"]  </td>
</tr>
</table>
<!-- / PRODUCTS TAB -->[/color]
[color="#000088"]<div style="line-height: 1pt"> </div>[/color]
[color="#000088"]{$tax_tab}[/color]
[color="#000088"]{if isset($order_invoice->note) && $order_invoice->note}
<div style="line-height: 1pt"> </div>
<table style="width: 100%">
<tr>
 <td style="width: 15%"></td>
 <td style="width: 85%">{$order_invoice->note|nl2br}</td>
</tr>
</table>
{/if}[/color]
[color="#000088"]{if isset($HOOK_DISPLAY_PDF)}
<div style="line-height: 1pt"> </div>
<table style="width: 100%">
<tr>
 <td style="width: 15%"></td>
 <td style="width: 85%">{$HOOK_DISPLAY_PDF}</td>
</tr>
</table>
{/if}[/color]
[color="#000088"]</div>[/color]
[color="#000088"]
Edited by shiggidydog (see edit history)
Link to comment
Share on other sites

  • 4 months later...

Hello !.

 

Interesting topic. Is there also a chance to add the product features in a new column instead all together ?. 

 

I have teas with its weight , but the weight has to be  in a new column.

 

For example:

 

PRODUCT

White Tea - 100 grms.

 

I need:

 

PRODUCT         WEIGHT

White Tea           100 grms

 

Thanks !!!!!!

Link to comment
Share on other sites

  • 2 months later...
  • 5 weeks later...

Yes! Solved changing row n.129 with this one:

<td style="text-align: left; width: 45%">{$order_detail.product_name} / {$order_detail.reference}</td>
Thanks!

 

For me it does not work, it simply doesn't show the number. Any ideea why? (I'm using PrestaShop™ 1.5.6.2). Thanks in advance.

 

Later edit: SOLVED using {counter} like this: <td style="text-align: left; width: 45%">{$order_detail.product_name} / {counter}</td>

Edited by dr06u (see edit history)
Link to comment
Share on other sites

  • 1 month later...

Hey, nice topic, people helping people!

 

I wonder, maybe someone can give me a hint: I have Prestashop 1.6 and suddenly my invoices lost the product lines, and only show the header and the total amount.

I have done nothing to make it like it is now, but I also can't find a solution to make it better...

 

Help? Anyone?...

Link to comment
Share on other sites

  • 7 months later...
  • 5 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...