Popular Post Supremacy2k Posted January 2, 2013 Popular Post Share Posted January 2, 2013 (edited) Greetings and Welcome to my first Guide. Today we're going over how to modify the look of the Invoices generated by Prestashop 1.5 used in the DEFAULT theme. (If you use a custom theme, check your themes/your_theme_name/ folder and check if there is a pdf folder inside, with *.tpl files. If so, modify those files, if not follow my steps below) First of all, feel free to translate this guide, and post it in your languages community. Before we proceed I have to notify you about the Disclaimer by PrestaShop which states: * 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. What that means, is that ALL changes made are LOST if you choose to upgrade your shop in the future. Notice: This Guide focuses on the Invoice template, and NOT Invoice-b2b template. (i don't use B2B invoices in my shop) Notice: If you use multi language in your shop, skip steps which states "Plain Text" as it doesn't change with the selected language. TABLE OF CONTENT : Preparing and Requirements. Goal and Example. 2.1. Explanation. Getting Started - Preparing files for modification. Creating the Header of the invoice. 4.1. Inserting the Logo and making a gab between Logo and Right Column. 4.2. Making the Right Column, for the Invoice Details. Inserting the Billing and Delivery addresses. Creating the products list. Creating rest of the file. Disclaimer and other info. 1. Preparing and Requirements. What is required to follow this guide: Basic programming skills. (HTML / CSS / PHP - Otherwise, Google is your friend.) I will NOT explain every programming tag used in this guide, only the highlights. Backup backup backup.. i can NOT stress this enough! What you need: Patience. (All good things takes time.) Lots of coffee. An order in your shop, to test the invoice template changes. What files are modified: header.tpl (referred to as header in this guide) invoice.tpl (referred to as invoice in this guide) Layout of this Guide: Line numbers: Are there to help me explain key elements of this guide. Remember to remove them! Yes i know they are annoying to remove, but i NEED them! Notices: Are in place for additional information regarding the layout. Again these files are found in /pdf/ in the root of your shop, OR under the theme you use. (/themes/your_theme/pdf/) By following this guide, you can modify the template to any look you desire. 2. Goal and Example. Here is an example of what we're going for. (Example is in Danish, i will explain below the picture, and the bottom of the invoice is cut off, no need for lots of white color and 1 line of company information here) 2.1 Explanation. To the right of the logo is the following fields, from the top. ( ) explains where it was before. Order Date. (Left of the products) (Format: Day-Month-Year Hours:Minutes) Invoice Number. (Top right) Order Number. (Left of the products) Salesman. (Not on the invoice at all) Payment Method. (Left of the products along with the amount) Right below logo, above the products, we find the following: Billing address Delivery address. (The example uses same billing and delivery address) Nothing is changed there, except I moved it to the center. Next the products list/fields are as following. Product Number/ID. (The field EAN13 when creating the product in BackOffice) Product/Reference. Unit price w/o tax. Unit price w/ tax. Discount. (Only shown if a discount is given, in the example, no discount is given) Number. Total price w/ tax. The rest is pretty much standard. Notice: All colors, text size etc. is set within the invoice file. 3. Getting Started - Preparing files for modification. I will only remind you of this 1 more time... BACKUP your files! First open up your header and delete everything below line 26. (the reason for this, is that the header file, don't have access to all required fields we want right of the logo) This includes: Complete order date (it only have access to the day of purchase, not the time) Order number. Payment Method. Save the file. Next open up invoice. Find line 27 and delete EVERYTHING below it. (yes there are 307 lines in this file.) On line 26, i chose to decrease the text size by 1pt. 01. <div style="font-size: 8pt; color: #444"> Change to 01. <div style="font-size: 7pt; color: #444"> Notice: The color: #444" is the color of the text in the invoice. 4. Creating the Header of the invoice. 4.1 Creating the Logo and the gab between Logo and Right Column. Next we will create the table that holds the entire invoice content: On line 28 insert the following: 01 <table width="100%"> 02 <tr> 03 <!-- LOGO --> 04 <td style="width: 35%"> 05 {if $logo_path} 06 <img src="{$logo_path}"/> 07 {/if} 08 </td> 09 <!-- END LOGO --> 10 <td style="width: 25%"> 11 12 </td> 13 <td style="width: 40%" align="right"> What we just did here, was the following: Line 01 - Created a table with the maximum allowed width within the invoice. Line 04 - Created a left column for the logo with a width of 35%. Line 06 - Inserted our logo. Line 10 - Created a center column that serves as a space between the logo and the right column with a width of 25% Line 13 - Created a right column with a width of 40% that holds the right invoice details. Notice: If your logo is too big for the left column with a width of 35%, you can adjust this by increasing the left column width, and decreasing the center column width to make it fit. 4.2 Creating the Right Column, for the Invoice Details. Next we have to create a new table in the right column to house our invoice details. This is done by inserting the following code on line 41: 01 <!-- INVOICE DETAILS --> 02 <table style="width: 100%"> 03 <tr> 04 <td style="width: 50%; text-align: right"> 05 {l s='Order Date:' pdf='true'} : 06 </td> 07 <td style="text-align: left"> 08 {$order->date_add|date_format:"%d-%m-%Y %H:%M"} 09 </td> 10 </tr> 11 <tr> 12 <td style="width: 50%; text-align: right"> 13 Fakturanummer : 14 </td> 15 <td style="text-align: left"> 16 {$title|replace:'Faktura #':'':'htmlall':'UTF-8'} 17 </td> 18 </tr> 19 <tr> 20 <td style="width: 50%; text-align: right"> 21 {l s='Order Number:' pdf='true'} : 22 </td> 23 <td style="text-align: left"> 24 {$order->getUniqReference()} 25 </td> 26 </tr> 27 <tr> 28 <td style="width: 50%; text-align: right"> 29 Sælger : 30 </td> 31 <td style="text-align: left"> 32 Online 33 </td> 34 </tr> 35 <tr> 36 <td style="width: 50%; text-align: right"> 37 {l s='Payment Method:' pdf='true'} : 38 </td> 39 <td style="text-align: left"> 40 <table style="width: 100%;"> 41 {foreach from=$order_invoice->getOrderPaymentCollection() item=payment} 42 <tr> 43 <td> 44 {$payment->payment_method} 45 </td> 46 </tr> 47 {foreachelse} 48 <tr> 49 <td> 50 {l s='No payment' pdf='true'} 51 </td> 52 </tr> 53 {/foreach} 54 </table> 55 </td> 56 </tr> 57 </table> 58 </td> 59 <!-- INVOICE DETAILS END --> A lot of code, i know. We just created the entire right column and all required fields. Below is the highlights of the code: Line 02 - We created the needed table for the invoice details, at 100% width of the right column, which is 40% of the invoice width. Line 05 - Order Date text. Changes with language. Line 08 - The actual date, time format is: day-month-year hours:minutes. Line 13 - Invoice number text. Plain text, correct this to match your current language. Line 16 - The actual invoice. The "replace:'Faktura #' part, strips away the text before the invoice number. (Change Faktura to match your language) I was pretty tired of looking at the #. Line 21 - Order number text. Changes with language. Line 24 - The actual order number. Line 29 - Salesman text. Plain text, correct this to match your current language. Line 32 - Online. This is a webshop, it's sold online, lets tell the customer that. Line 37 - Payment Method text. Changes with language. Line 40 - 54 - PrestaShop's code for determine payment method, DO NOT ALTER THIS! End the table of the header, and make a space between the logo and billing/delivery address(es) Insert the following on line 100: </td> </tr> </tbody></table> <p> </p> 5. Inserting the Billing and Delivery addresses. Next we need a new table to house the address/delivery address(es). Insert the following code on line 103: 01 <!-- ADDRESSES --> 02 <table style="width: 100%"> 03 <tr> 04 <td> 05 {if !empty($delivery_address)} 06 <table style="width: 100%;"> 07 <tr> 08 <td style="width: 15%"></td> 09 <td style="width: 35%; font-size: 6pt"><b>{l s='Delivery Address' pdf='true'} :</b><br /><br /> 10 {$delivery_address} 11 </td> 12 <td style="width: 35%; font-size: 6pt"><b>{l s='Billing Address' pdf='true'} :</b><br /><br /> 13 {$invoice_address} 14 </td> 15 <td style="width: 15%"></td> 16 </tr> 17 </table> 18 {else} 19 <table style="width: 100%"> 20 <tr> 21 <td style="width: 15%"></td> 22 <td style="width: 35%"><b>{l s='Billing & Delivery Address.' pdf='true'}</b><br /><br /> 23 {$invoice_address} 24 </td> 25 <td style="width: 35%"> </td> 26 <td style="width: 15%"></td> 27 </tr> 28 </table> 29 {/if} 30 </td> 31 </tr> 32 </table> 33 <!-- / ADDRESSES --> The following code creates a table to house the addresses, with a 15% space on each side. (Left and Right) You should have no need to change anything here, unless you think the space on the left and right are too much, you can than on line 08+15+21+26 decrease the 15% and on line 09+12+22+25 increase the 35% corresponding to the 15% Insert the following code on line 136, to create a gab between the addresses and the product listings. <div style="line-height: 1pt"> </div> 6. Creating the products list. Next is the products tab, which shows all bought items and related information. This part will be explained in sections, as it is 183 lines of code. Most of the code i will jump over quite quickly as it is standard code, and no changes has been made. Start by inserting the following code on line 138: <!-- PRODUCTS TAB --> <table style="width: 100%"> <tbody><tr> <td style="text-align: right"> This code starts the table for the products. Insert the following code on line 148 : <td style="text-align: left; width: 10%; font-weight: bold">Nummer</td> This line inserts the Product ID text, this text will not change with language, change it to your current language. Insert this next chunk of code on line 149: <td style="text-align: left; width: 45%; font-weight: bold">{l s='Product / Reference' pdf='true'}</td> <!-- unit price tax excluded is mandatory --> {if !$tax_excluded_display} <td style="text-align: right; width: 12%; font-weight: bold">{l s='Unit Price' pdf='true'} {l s='(Tax Excl.)' pdf='true'}</td> {/if} <td style="text-align: right; width: 12%; font-weight: bold"> {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="text-align: right;width: 6%; font-weight: bold">{l s='Qty' pdf='true'}</td> <td style="text-align: right;width: 15%; font-weight: bold"> {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:4px;background-color:{$bgcolor};"> The code for the rest of the products text, product name, taxes, units and so on. Notice: values='#FFF,#DDD' cycles the background color of the products, from white to gray. Remember we created a field for the product number/ID ? It's time to get the actual product number/ID inserted in front of the product name. Insert the following on line 176: <td style="text-align: left; width: 10%;">{$order_detail.product_ean13}</td> This inserts the EAN13 number used in BackOffice to your Invoice template, so the customer can quickly look up the same product in your shop, by searching for the EAN13 number. 7. Creating rest of the file. The rest of the code is unchanged, so i will not annoy you by inserting line numbers on the following 178 lines of code. Insert the following code on line 177: <td style="text-align: left; width: 45%">{$order_detail.product_name}</td> <!-- unit price tax excluded is mandatory --> {if !$tax_excluded_display} <td style="text-align: right; width: 12%"> {displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_excl} </td> {/if} <td style="text-align: right; width: 12%"> {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: 6%">{$order_detail.product_quantity}</td> <td style="width: 15%; text-align: right; width: 15%"> {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:4px;background-color:{$bgcolor}; "> <td style="line-height:3px; text-align: left; width: 60%; vertical-align: top"> <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} {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 --> <!-- CART RULES --> {assign var="shipping_discount_tax_incl" value="0"} {foreach $cart_rules as $cart_rule} {cycle values='#FFF,#DDD' assign=bgcolor} <tr style="line-height:4px;background-color:{$bgcolor};" text-align="left"> <!-- <td colspan="{if !$tax_excluded_display}5{else}4{/if}">{$cart_rule.name}</td> --> <td></td><td colspan="3">{$cart_rule.name}</td><td style="text-align: right">1</td> <td> {if $cart_rule.free_shipping} {assign var="shipping_discount_tax_incl" value=$order_invoice->total_shipping_tax_incl} {/if} {if $tax_excluded_display} - {$cart_rule.value_tax_excl} {else} - {$cart_rule.value} {/if} </td> </tr> {/foreach} <!-- END CART RULES --> </table> <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> <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} {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} {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} {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} {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} <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> </table> </td> </tr> </table> <!-- / PRODUCTS TAB --> <div style="line-height: 1pt"> </div> {$tax_tab} {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} {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} <table style="width: 100%;"> <tr> <td style="width: 17%"></td> <td style="width: 66%">{if $available_in_your_account}{l s='An electronic version of this invoice is available in your account. To access it, log in to our website using your e-mail address and password (which you created when placing your first order).' pdf='true'}{/if}</td> </td style="width: 17%"></td> </tr> </table> </div> 8. Disclaimer and other info. First off, thanks for reading this guide, I really hope you enjoyed it, and it was useful to you. It took me close to 4 hours writing it. Now the serious part. I will not be held responsible if you mess up your files, or other wise breake your webshop. This guide is only used as an example on how you can modify your invoice template, to fit your needs. I will not be held responsible for typos, errors in the code (it does however work on my shop), and other funny things that might have snuck in, during writing this. I only had between 1.5 and 2 hours of sleep, and WAY to much coffee writing this. Critcism, ideas and other such replies are welcome. To quote Wikipedia. A critic is anyone who expresses a value judgment. Informally, criticism is a common aspect of all human expression and need not necessarily imply skilled or accurate expressions of judgment. Critical judgments, good or bad, may be positive (in praise of an object of attention), negative (in dispraise), or balanced (weighing a combination of factors both for and against). Since all criticism must be regarded as having a purpose, a critic may also be definable by his or her specific motivation. At its simplest, and for whatever reason, a critic may have either constructive or destructive intent.</div> Ps. If anybody know how to make Anchors in this forum, so i can link my Table of Content, please sent me a private message on how to do that, to keep this topic free of non-related posts. Best Regards - Kris. Edit: Attached files, remember to rename them to .tpl header.txt invoice.txt Edited January 4, 2013 by Supremacy2k (see edit history) 33 1 Link to comment Share on other sites More sharing options...
anderskiel Posted January 4, 2013 Share Posted January 4, 2013 Very comprehensive guide Kris. Thanks! For those of us who are strugling with patience and skills would you be so kind to share your edited files? Thanks Anders 1 Link to comment Share on other sites More sharing options...
Supremacy2k Posted January 4, 2013 Author Share Posted January 4, 2013 2 files are attached in first post. header.txt and invoice.txt Files should be renamed to header.tpl and invoice.tpl Link to comment Share on other sites More sharing options...
anderskiel Posted January 4, 2013 Share Posted January 4, 2013 Super thank you. I now have a very nice looking invoice :-) However i have a bit too much space above the logo. How do i decrease this? Thanks. Anders Link to comment Share on other sites More sharing options...
XtreM726 Posted January 4, 2013 Share Posted January 4, 2013 where is footer.tpl files ? Link to comment Share on other sites More sharing options...
Supremacy2k Posted January 4, 2013 Author Share Posted January 4, 2013 Footer files are not altered. You can find them in your PDF folder. In the top of this guide is a list of files that is subject to changes. :-) Link to comment Share on other sites More sharing options...
Jamshaid Hashmi Posted January 6, 2013 Share Posted January 6, 2013 (edited) how can I change {$invoice_address} and {$delivery_address} format. Company name (bold) or font size 18 firstname lastname (small) address1, address2 city, country actually I need this format on every document Edited January 6, 2013 by Jamshaid Hashmi (see edit history) 1 Link to comment Share on other sites More sharing options...
m3442a Posted January 6, 2013 Share Posted January 6, 2013 (edited) After copy the code in my invoice.tpl i became this error: Warning: Division by zero in /www/htdocs/....../....../....../....../tools/tcpdf/tcpdf.php on line 23203 Warning: array_fill() [function.array-fill]: Number of elements must be positive in /www/htdocs/....../....../....../....../tools/tcpdf/tcpdf.phpon line 23205 Warning: Invalid argument supplied for foreach() in /www/htdocs/....../....../....../....../tools/tcpdf/tcpdf.php on line 24618 Warning: Invalid argument supplied for foreach() in /www/htdocs/....../....../....../....../tools/tcpdf/tcpdf.php on line 24650 TCPDF ERROR: Some data has already been output, can't send PDF file Edited January 6, 2013 by m3442a (see edit history) Link to comment Share on other sites More sharing options...
Supremacy2k Posted January 6, 2013 Author Share Posted January 6, 2013 This guide is for prestashop version 1.5, not 1.4 I can't help you with your error. :-( Link to comment Share on other sites More sharing options...
m3442a Posted January 6, 2013 Share Posted January 6, 2013 I have PS Version 1.5.2. Maybe is an error in your code? The template is very nice, thanks for that, but dont working Link to comment Share on other sites More sharing options...
Supremacy2k Posted January 6, 2013 Author Share Posted January 6, 2013 (edited) Well then its at 1.4 upgraded to 1.5, because 1.5 do not have a "tools" folder. And in that case I'm not sure what your problem is, because I'm not getting any errors on my shop, which is live. :/ Edit: I can see you get your error in the .php file, and not the tpl file. Edited January 7, 2013 by Supremacy2k (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted January 7, 2013 Share Posted January 7, 2013 very nice guide, thanks for sharing! v1.5 does indeed include a tools folder, which is where all the plugins and 3rd party libraries are stored. The error is occuring in the writeHTML function of tcpdf.php. Most likely something in the invoice.tpl is not correct or conflicting with the users specific installation. It would need to be debugged further to understand the problem. Link to comment Share on other sites More sharing options...
Supremacy2k Posted January 7, 2013 Author Share Posted January 7, 2013 Okey I'm blind. I totally missed the "tools" folder, hehe. Anyways. On line 23.203 i have the following: } else { on 23.205 i have this: } On 24.618 this: $this->y += $this->getHTMLUnitToUnits($table_el['attribute']['cellspacing'], 1, 'px'); and on 24.650 this if (isset($this->theadMargins['top'])) { m3442a .. can you post your lines from 24203 to 24205 and from 24618 to 24650 ? Link to comment Share on other sites More sharing options...
Supremacy2k Posted January 7, 2013 Author Share Posted January 7, 2013 how can I change {$invoice_address} and {$delivery_address} format. Company name (bold) or font size 18 firstname lastname (small) address1, address2 city, country actually I need this format on every document To be honest I'm not quite sure where address text is generated. I havent looked into it, and might go beyond my skills for now. Link to comment Share on other sites More sharing options...
Woutermesker Posted January 8, 2013 Share Posted January 8, 2013 (edited) Hi, I used a little info from this topic, attached my result. Wouter Edited January 8, 2013 by Woutermesker (see edit history) 1 Link to comment Share on other sites More sharing options...
Supremacy2k Posted January 9, 2013 Author Share Posted January 9, 2013 Looks good. But you should try remove the Faktura # text in your header, so it's just Faktura: NL00001 or whatever. 1 Link to comment Share on other sites More sharing options...
troyrob Posted January 10, 2013 Share Posted January 10, 2013 Hello question? How would i insert Product reference number instead of EAN number instead? 1 Link to comment Share on other sites More sharing options...
Supremacy2k Posted January 10, 2013 Author Share Posted January 10, 2013 on line 176 : <td style="text-align: left; width: 10%;">{$order_detail.product_ean13}</td> insert : <td style="text-align: left; width: 10%;">{$order_detail.product_reference}</td> should do it. 1 Link to comment Share on other sites More sharing options...
alda81 Posted January 12, 2013 Share Posted January 12, 2013 thanks Supremacy2k for your guide Hi, I used a little info from this topic, attached my result. Wouter hi, do you think that you can post your files with adaptation? thank you Link to comment Share on other sites More sharing options...
mishamean Posted January 26, 2013 Share Posted January 26, 2013 Hi, I made some alterations to my invoice also. But at the reference number/order number I can't make that show. I tried inseting {$order_detail.product_reference} but on the PDF I see only a blank space and then I looked at your guide and tried with {$order_detail.product_ean13} . The result is the same. I don't understand what I did wrong with the invoice template because all the other cells and data in them are shown properly. Can anybody give me some pointers to what should I try next? Thanks Link to comment Share on other sites More sharing options...
Supremacy2k Posted January 26, 2013 Author Share Posted January 26, 2013 What version of prestashop are you using? 1 Link to comment Share on other sites More sharing options...
mishamean Posted January 26, 2013 Share Posted January 26, 2013 I'm using PrestaShoop 1.5.3.1 Link to comment Share on other sites More sharing options...
Supremacy2k Posted January 26, 2013 Author Share Posted January 26, 2013 hmm wierd... it should work. I got a lot of work the next week or so, but im not gonna forget your question, and i will get back to you. Link to comment Share on other sites More sharing options...
spott Posted February 1, 2013 Share Posted February 1, 2013 Hi I have the same problem with EAN codes - it is blank. All other fields are fine. Latest stable PrestShop. Hi, I made some alterations to my invoice also. But at the reference number/order number I can't make that show. I tried inseting {$order_detail.product_reference} but on the PDF I see only a blank space and then I looked at your guide and tried with {$order_detail.product_ean13} . The result is the same. I don't understand what I did wrong with the invoice template because all the other cells and data in them are shown properly. Can anybody give me some pointers to what should I try next? Thanks Link to comment Share on other sites More sharing options...
Supremacy2k Posted February 2, 2013 Author Share Posted February 2, 2013 (edited) are you both sure you actually have something written in either reference or ean13 for your products? Edited February 2, 2013 by Supremacy2k (see edit history) Link to comment Share on other sites More sharing options...
mishamean Posted February 2, 2013 Share Posted February 2, 2013 Yes. I'm pretty sure I have. Link to comment Share on other sites More sharing options...
mohamadeffazuan Posted February 6, 2013 Share Posted February 6, 2013 Kris, Do you know how to change the total price position to the bottom. I've try to amend invoice.tpl but it only works in the first page, if there is 2nd page or above, it's not at the bottom. You can see the attachment for reference. I'm using PS 1.5 Pls help Thank you Link to comment Share on other sites More sharing options...
aqwzsx159 Posted February 6, 2013 Share Posted February 6, 2013 Hi, I've the same problem, I want to mpdify my invoice template but it's not very pretty. the TCPDF don't say about margin padding ... cdlt Link to comment Share on other sites More sharing options...
infinityl Posted February 6, 2013 Share Posted February 6, 2013 (edited) And if i want to show a feature value of the product named "idacs" instead the {$order_detail.product_reference}??? Edited February 6, 2013 by infinityl (see edit history) Link to comment Share on other sites More sharing options...
Supremacy2k Posted February 8, 2013 Author Share Posted February 8, 2013 Hi guys. Thanks for your patience. I would like you all to post a comment with your invoice files. and i will go over them in the weekend, and test them ofc. - Kris. Link to comment Share on other sites More sharing options...
eleazar Posted February 17, 2013 Share Posted February 17, 2013 OMG, Supremacy2k, you've just made my day!! Saved me a lot of time (and coffee lol). Just a few changes left and it's perfect for me in Germany. Many many thx. Rainer Link to comment Share on other sites More sharing options...
John_John Posted February 21, 2013 Share Posted February 21, 2013 (edited) i would like to know as well how to remove the (empty) header.tpl margin [sOLVED] Found the solution myself. Goto /classes/pdf/PDFgenerator.php Around line 155 you will see $this->setMargins(10, 40, 10); Change it to $this->setMargins(10, 10, 10); Edited February 21, 2013 by John_John (see edit history) 3 Link to comment Share on other sites More sharing options...
the hat lady Posted February 23, 2013 Share Posted February 23, 2013 I would like to add the carrier on the invoice like the old ones had. Does anyone know the code??? Link to comment Share on other sites More sharing options...
mehnihma Posted February 23, 2013 Share Posted February 23, 2013 Is there a way to set only one currency in invoice template? If costumer buys in dollars but Invoice to be in EURO always? Link to comment Share on other sites More sharing options...
eleazar Posted February 23, 2013 Share Posted February 23, 2013 (edited) Found a similar solution in the french forum: http://www.prestasho...-prestashop-15/ This version contains a section for display weight, carrier and tracking ID I used just as option for my own slightly modified invoice.tpl, which is attached as pdf. (Full coding you find here: http://www.prestasho...36#entry1117036 ) <!-- Optional display of weight, carrier and tracking ID --> {foreach from=$order->getShipping() item=shipping name=shippingsLoop} <table style="width: 100%; text-align: center; border: 1px solid #CCC; font-size: 9pt;"> <tr> <td colspan = "3" style="background-color: #CCC; color: #000;"> <b>{l s='Paket Nr. ' pdf='true'}{$smarty.foreach.shippingsLoop.iteration}</b> </td> </tr> <tr> <td style="width: 33%; background-color: #EEE; color: #000;"> <b>{l s='Gewicht:' pdf='true'}</b> </td> <td style="width: 33%; background-color: #EEE; color: #000;"> <b>{l s='Versanddienst:' pdf='true'}</b> </td> <td style="width: 34%; background-color: #EEE; color: #000;"> <b>{l s='Tracking-Nr.:' pdf='true'}</b> </td> </tr> <tr> <td style="width: 33%;"> {$shipping.weight|string_format:"%.3f"} Kg </td> <td style="width: 33%;"> {$shipping.state_name} </td> <td style="width: 34%;"> {$shipping.tracking_number} </td> </tr> </table> {/foreach} For printouts on own business paper I recommend just to deactivate line 73 and 74 in /classes/pdf/pdf.php with /* ... */: $this->pdf_renderer->createHeader($template->getHeader()); $this->pdf_renderer->createFooter($template->getFooter()); If the billing address doesn't fit, either change the margins in /classes/pdf/PDFgenerator.php or adjust table width from 100% to about 92%, which matches about 1in for left margin. Anyhow, as our tax laws in Germany are very complicated, I got an urgent request too: Does anybody know how to display the tax rate for each product in every line of the invoice's products section? It's jinxed, but I just can't manage it. I really have no idea. Edited February 23, 2013 by eleazar (see edit history) 2 Link to comment Share on other sites More sharing options...
Berlindoor Posted February 26, 2013 Share Posted February 26, 2013 anybody knows if it's possible to add a separate CSS to the invoice template? Link to comment Share on other sites More sharing options...
eleazar Posted February 26, 2013 Share Posted February 26, 2013 (edited) Why not? If you're desperate to include the reference to any particular style in the invoice.tpl, it should work. Maybe even with a separate css file if you activate option Smart Cache for CSS. This forces PrestaShop to conbine all css files into a single file. Edited February 26, 2013 by eleazar (see edit history) Link to comment Share on other sites More sharing options...
Berlindoor Posted February 26, 2013 Share Posted February 26, 2013 (edited) Anyhow, as our tax laws in Germany are very complicated, I got an urgent request too: Does anybody know how to display the tax rate for each product in every line of the invoice's products section? It's jinxed, but I just can't manage it. I really have no idea. you could have a look into the template of ps1.4 (if nobody changed the name of the methods/functions for 1.5) Edited February 26, 2013 by andrep (see edit history) Link to comment Share on other sites More sharing options...
Berlindoor Posted February 26, 2013 Share Posted February 26, 2013 Why not? If you're desperate to include the reference to any particular style in the invoice.tpl, it should work. Maybe even with a separate css file if you activate option Smart Cache for CSS. This forces PrestaShop to conbine all css files into a single file. didn't try with smart cache for CSS (I already started coding the template without it), but without didn't work Link to comment Share on other sites More sharing options...
cammo Posted February 26, 2013 Share Posted February 26, 2013 Does anyone know of anyone sharing their customised invoice templates? Be nice if there was some nice looking ones already made that people were willing to share, could save me some time! Link to comment Share on other sites More sharing options...
Berlindoor Posted February 26, 2013 Share Posted February 26, 2013 (edited) Does anyone know of anyone sharing their customised invoice templates? Be nice if there was some nice looking ones already made that people were willing to share, could save me some time! Here we are if you want you can share your work on this page Edited February 26, 2013 by andrep (see edit history) 3 Link to comment Share on other sites More sharing options...
cammo Posted February 26, 2013 Share Posted February 26, 2013 With the modifications explained in the OP, this removes the content from the header.tpl file and inserts it into the invoice.tpl file. That's fine, however the invoice then has a large gap at the top where the header should be, since the header file is now empty. Is there any way to move the invoice.tpl content higher to the top of the page, i.e. reduce the height of the header.tpl allowance within the PDF? Link to comment Share on other sites More sharing options...
Supremacy2k Posted February 26, 2013 Author Share Posted February 26, 2013 I'll been fighting with this my self. The reason why i chose to move the header content into the main document, was because the header.tpl don't have access to all variables used with this invoice template. The major factor was the order number. How to either remove the header.tpl from this template or reduces it's occupied space on the pdf, i don't know. Link to comment Share on other sites More sharing options...
eleazar Posted February 26, 2013 Share Posted February 26, 2013 @cammo & Supremacy2k Is there any way to move the invoice.tpl content higher to the top of the page, i.e. reduce the height of the header.tpl allowance within the PDF? How to either remove the header.tpl from this template or reduces it's occupied space on the pdf, i don't know So once again what JohnJohn already posted on page 2 of this thread: You may reduce space for header or footer in lines 153 and 154 of /classes/pdf/PDFgenerator.php: * Write a PDF page */ public function writePage() { $this->SetHeaderMargin(5); $this->SetFooterMargin(18); $this->setMargins(10, 40, 10); $this->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM); $this->AddPage(); $this->writeHTML($this->content, true, false, true, false, ''); } 2 Link to comment Share on other sites More sharing options...
cammo Posted February 27, 2013 Share Posted February 27, 2013 So to do an override of the PDFgenerator.php class, do I simply duplicate the file into the overrides folder override\classes\pdf\ and make my modifications, or do you simply put the modified bit of code into the override file? Link to comment Share on other sites More sharing options...
eleazar Posted February 27, 2013 Share Posted February 27, 2013 (edited) No, don't just duplicate the file! You need to replace class PDFGeneratorCore extends TCPDF with this line already written in the overrrides file: class PDFGenerator extends PDFGeneratorCore With this modifications you may copy the whole file to /overrides/pdf. Or you just modify the funktion with an overrides file containing just the function with your range modification like shown below: <? class PDFGenerator extends PDFGeneratorCore { * Write a PDF page */ public function writePage() { $this->SetHeaderMargin(5); $this->SetFooterMargin(18); $this->setMargins(10, 40, 10); $this->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM); $this->AddPage(); $this->writeHTML($this->content, true, false, true, false, ''); } } Full modified copy does work, in case of the second I'm not quite sure. Normally I use the full mode. Edited February 27, 2013 by eleazar (see edit history) Link to comment Share on other sites More sharing options...
blueraccoon Posted February 27, 2013 Share Posted February 27, 2013 Excellent work here guys. Thanks to all for input. Has anyone created templates for the other order files? Such as delivery slip, return etc? Cheers. Link to comment Share on other sites More sharing options...
cammo Posted February 27, 2013 Share Posted February 27, 2013 Thanks Eleazar, I used the second method of just copying the function into the override file and it's all good! Link to comment Share on other sites More sharing options...
spott Posted February 28, 2013 Share Posted February 28, 2013 Hi How Is possible to add order comments also to invoice? Link to comment Share on other sites More sharing options...
dklap3 Posted March 4, 2013 Share Posted March 4, 2013 @ Supremacy2k: Thanks a lot for this guide, it made my day. :-) A related question: Does anyone know how I can add the customers phone number to the pdf invoice? I'm using v. 1.5.3.1 I have tried editing the address format in "cuntries" but it doesn't seem to do anything. Link to comment Share on other sites More sharing options...
eleazar Posted March 4, 2013 Share Posted March 4, 2013 @dklap3 Sounds weird. I think you should either delete the smarty cache in \cache\smarty\cache and \cache\smarty\compile or switch for one time to Force compile in Advanced Parameters second menu item in section Smarty.(Then switch back to normal mode. Slows down your shop system) Then your modifications should work. Link to comment Share on other sites More sharing options...
dklap3 Posted March 4, 2013 Share Posted March 4, 2013 @ eleazer: thank you for the reply. I think I found the problem. In "country", when trying to add the phone, I clicked "Address" > "phone_mobile" which added a "Address:phone_mobile" to the format field. This didn't show up on my invoice. However, deleting the first part and just writing "phone_mobile" made it show up..not sure why but a bit confusing. Anyway it works now. On last thing: Do you also know if I can possibly add a little "(Tlf)", or any other text, after or before the phone number? My adress format includes 2 things with 8 numbers (phone and tax nr.) and I would like to add such a little text next to them to avoid confusion. Link to comment Share on other sites More sharing options...
eleazar Posted March 4, 2013 Share Posted March 4, 2013 Nope, inserting other text isn't allowed here. Just the field names. And in future you should better klick on the button "Apply standard" or something like that (sorry, but my buttons are in German) displayed below the field as second one. This forces PrestaShop to dislplay all valid field names and you avoid misspelling. Anyhow, it should be possible to add some text to the billing or delivery address, but that's a bit tricky because you have to modify the core file where the address formats are generated. PDFs in PrestaShop just display these elsewhere generated address formats. Link to comment Share on other sites More sharing options...
dklap3 Posted March 4, 2013 Share Posted March 4, 2013 Thank you again for the answer eleazar. I might try to modify the core files later, but for now I found another more simple solution. For my new invoice (based on the example in this thread), I have just added the text manually in the <td> next to the address. All the fields in the address are mandatory, so I'm sure it will be the same fields used every time. It's in Danish, but you'll probably get it: Link to comment Share on other sites More sharing options...
Yankee Store Posted March 12, 2013 Share Posted March 12, 2013 hello Is there a way to sort products by 1) category 2) by name 3) and then price . am looking to simply filling orders by having tiese sorts on invoice for picking purposes. Thank you for any help in this matter Link to comment Share on other sites More sharing options...
mehnihma Posted March 14, 2013 Share Posted March 14, 2013 HI is it possible to add seller name who confirmed order in invoice, how to get that variable? Thanks Link to comment Share on other sites More sharing options...
webdisplay Posted March 19, 2013 Share Posted March 19, 2013 Great job! Works like a charm with 1.5.3.1 (Rigtig flot arbejde Supremacy2k!) Link to comment Share on other sites More sharing options...
Hsell Posted March 22, 2013 Share Posted March 22, 2013 Great post. Learned a lot today... Even though still a newbie managed to fit the adresses to work with my peel of labels and did some other design changes. Although the one thing I can not seam to find and modify is the the table with total tax under the product table? I see something called {$tax_tab} but not sure how to modify. I primarily would like to adjust the background for the titles and potentially move it. A perfect continuation of this guide/post would be some guidence how to modify the delivery slip as well? Although after this guide I feel confident enough to have a look at least... Link to comment Share on other sites More sharing options...
charliedonsurf Posted April 8, 2013 Share Posted April 8, 2013 Great Info here! I learned so much! Quick question: Anyone know how to create seperate invoices for different countries and have the system recognize this? I would be interested in having two seperate types of invoices, one for my clients in Switz and the others for Germany/ france. Thanks! Link to comment Share on other sites More sharing options...
mschadegg Posted April 11, 2013 Share Posted April 11, 2013 Really nice guide. How do I get the carrier and the tracking id ? Link to comment Share on other sites More sharing options...
j3velez Posted April 15, 2013 Share Posted April 15, 2013 Do you know how to create invoices only for a specific customer group? or avoid to create invoices for a specific customer group? Link to comment Share on other sites More sharing options...
longip Posted April 26, 2013 Share Posted April 26, 2013 What do I need to modify to have one invoice template in FO and another invoice template in BO. Obviously, I know that I need 2 templates. Link to comment Share on other sites More sharing options...
Rhapsody Posted April 28, 2013 Share Posted April 28, 2013 I have found this post very useful. Currently when I upgrade Prestashop, I keep a folder on my local drive that includes the modified .tpl files to upload into the PDF directory after an upgrade. I was wondering if it would be possible to create a PDF directory in my custom theme directory that inludes the .tpl files, then have an Override file in override/classes/pdf that would force the PDF generation to pickup the modified template files in my custom theme? That would simplify upgrading for everyone. Anybody care to take this on, or suggest a similar approach so that autoupgrade doesn't overwrite the customized PDF files? Link to comment Share on other sites More sharing options...
eleazar Posted April 28, 2013 Share Posted April 28, 2013 Hi Rhapsody, why so complicated. It's totally simple. Just create the pdf directory in your custom themes directory. The files you put here will automatically override the default PDF files. That's all. No additional change necessary. Same solution possible for the mails directory, if you apply some modifications here, too. 1 Link to comment Share on other sites More sharing options...
Rhapsody Posted April 29, 2013 Share Posted April 29, 2013 eleazar - I wasn't aware that could be done. I tried it and it works fine. Thanks very much for the suggestion. Link to comment Share on other sites More sharing options...
peeke Posted May 6, 2013 Share Posted May 6, 2013 Okey I'm blind. I totally missed the "tools" folder, hehe. Anyways. On line 23.203 i have the following: } else { on 23.205 i have this: } On 24.618 this: $this->y += $this->getHTMLUnitToUnits($table_el['attribute']['cellspacing'], 1, 'px'); and on 24.650 this if (isset($this->theadMargins['top'])) { m3442a .. can you post your lines from 24203 to 24205 and from 24618 to 24650 ? this error is normal when there is a typo in your invoice.txt <table style="width: 100%;"> <tr> <td style="width: 17%"></td> <td style="width: 66%">{if $available_in_your_account}{l s='An electronic version of this invoice is available in your account. To access it, log in to our website using your e-mail address and password (which you created when placing your first order).' pdf='true'}{/if}</td> </td style="width: 17%"></td> </tr> </table> You have a closing td instead of an opening td in the last td rule Link to comment Share on other sites More sharing options...
eleazar Posted May 9, 2013 Share Posted May 9, 2013 Does anybody know of you guys how I manage to add the gender to both invoice and delivery address, so that you get something like Mrs Ronda Nuttleback ,,, in invoice.tpl This really drives me mad because I don't know how to solve this problem and in Germany a personalized address format is the normal case. Link to comment Share on other sites More sharing options...
Rhapsody Posted May 16, 2013 Share Posted May 16, 2013 I have some custom fields defined in the ps_customer table. In the old 1.4 PS I was able to include these in the PDF.php override file to have them display on the PDF invoice. Can I do similar using just the template files with 1.5? For example - the custom field names in the ps_customer table are member and spouse. If the customer purchase products with ID 6, 10, 15, 17 or 26 then display a section on the invoice that includes the custom fields. Bellini helped me with this as on override for my custom invoice in PS 1.4. I'm doing other shop mods and getting ready to upgrade a shop from 1.4.10.0 to 1.5. The customized invoice is the last item I need to make work. What I want to do is check if certain products were purchased, and if they were, display a section with the custom field names. Link to comment Share on other sites More sharing options...
ramesh90 Posted May 21, 2013 Share Posted May 21, 2013 Hi, i want to remove logo from order invoice.how to do...? Link to comment Share on other sites More sharing options...
eleazar Posted May 21, 2013 Share Posted May 21, 2013 Hi, ramesh90, just logo or complete header? How-to for removing the complete header I already posted here: http://www.prestashop.com/forums/index.php?/topic/213664-guide-modifying-prestashop-15-invoice-template/page__view__findpost__p__1119146 To remove just the logo you have to open /pdf/header.tpl and disable line 28-30 like this: {* {if $logo_path} <img src="{$logo_path}" style="width:{$width_logo}px; height:{$height_logo}px;" /> {/if} *} Link to comment Share on other sites More sharing options...
desudura Posted May 23, 2013 Share Posted May 23, 2013 guys how do i remove the top space from my invoice, that's the exact space for the old header which i removed thank you IN000020-14.pdf Link to comment Share on other sites More sharing options...
eleazar Posted May 23, 2013 Share Posted May 23, 2013 (edited) guys how do i remove the top space from my invoice, that's the exact space for the old header which i removed Hi desudura, I guess you just deactivated the header printout in /classes/pdf/pdf.php by disabling the line $this->pdf_renderer->createHeader($template->getHeader()); But by doing this a white space is the only result. You need to modify function writePage() in /classes/pdf/PDFgenerator.php. Looks like this: public function writePage() { $this->SetHeaderMargin(5); $this->SetFooterMargin(18); $this->setMargins(10, 40, 10); $this->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM); $this->AddPage(); $this->writeHTML($this->content, true, false, true, false, ''); } Measures are in mm. You have to modify line 183 (v 1.5.3.x) or line 153 (v 1.5.4.x) to $this->SetHeaderMargin(5); if your measure is mm here. Search forfunction __construct. There must be a line like this: parent::__construct('P', 'mm', 'A4', true, 'UTF-8', $use_cache, false); If, as I don't know, your linear measurement is different, you got to modify this entry too. If all this doesn't help I would guess that you didn't insert the framed text and logo of you header to header.tpl (where it belongs) but to invoice.tpl. If so, then move this complete table to header.tpl and replace the code in this file with your own header code. Edited May 24, 2013 by eleazar (see edit history) 1 Link to comment Share on other sites More sharing options...
desudura Posted May 24, 2013 Share Posted May 24, 2013 thank you Link to comment Share on other sites More sharing options...
jkousholt Posted May 24, 2013 Share Posted May 24, 2013 Okey I'm blind. I totally missed the "tools" folder, hehe. Anyways. On line 23.203 i have the following: } else { on 23.205 i have this: } On 24.618 this: $this->y += $this->getHTMLUnitToUnits($table_el['attribute']['cellspacing'], 1, 'px'); and on 24.650 this if (isset($this->theadMargins['top'])) { m3442a .. can you post your lines from 24203 to 24205 and from 24618 to 24650 ? I have the same error. Since m3442a haven't posted the lines, I would be happy to do it, if you're still are willing to help? Link to comment Share on other sites More sharing options...
YanK1973 Posted May 30, 2013 Share Posted May 30, 2013 I have a strange problem, i've been using a really good looking invoice template cardscapital created and shared here but for some reason, it shows two carriers when i only have one carrier from back office. It still shows "my carrier" first and below that my actual carrier..any ideas? Link to comment Share on other sites More sharing options...
desudura Posted June 13, 2013 Share Posted June 13, 2013 How can I add the DNI field, required on account creation into the invoice, next to name?!?! thank you Link to comment Share on other sites More sharing options...
Rhapsody Posted June 17, 2013 Share Posted June 17, 2013 I have now customized my 1.5.4.1 invoice and added the special "logic" for the membership cards I wanted to include for printing when membership is purchased. Has anyone figured out how to modify the display of product attributes? Currently it is a run on string with the attribute name, followed by a colon, then the attribute. I would like to display each attribute and value on a separate line, similar to the way product customizations are displayed. Link to comment Share on other sites More sharing options...
Rhapsody Posted June 17, 2013 Share Posted June 17, 2013 (edited) [solved] How to make product attributes and groups (combinations in the BO for products) display on separate lines of the PDF invoice. ... Has anyone figured out how to modify the display of product attributes? Currently it is a run on string with the attribute name, followed by a colon, then the attribute. I would like to display each attribute and value on a separate line, similar to the way product customizations are displayed. I figured it out. The following can be put in the invoice.tpl file as a modification:Search for: <td style="text-align: left; width: 45%">{$order_detail.product_name}</td> and replace with the following <td style="text-align: left; width: 45%">{$order_detail.product_name|replace:', ':'<br>'|replace:' - ':'<br>'}</td> This has the effect of making the product description display like this: This is the product description with the assigned attributes Attribute1 : Value 1 Attribute2 : Value2 Attribute3 : Value3 Attribute4 : Value4 instead of displaying like this: This is the product description with the assigned attributes - Attribute1 : Value 1, Attribute2 : Value2, Attribute3 : Value3, Attribute4 : Value4 Edited June 17, 2013 by Rhapsody (see edit history) Link to comment Share on other sites More sharing options...
MassiveRC Posted June 19, 2013 Share Posted June 19, 2013 I'm trying to save on ink and want to lighten the black bars for Product/Reference and Tax Detail. I'd be happy just using a white background and having regular black lettering. Can some [spam-filter] tell me what fields to change if it's that easy? Thanks. Link to comment Share on other sites More sharing options...
Rhapsody Posted July 1, 2013 Share Posted July 1, 2013 (edited) Solved: How can customer messages be displayed in the pdf invoice? Jump to the bottom of this post for the solution - thanks to pointers from Bellini13! I'm looking for the method to display messages on the pdf invoice that are displayed in the order history and the BO order display. In the front office when a customer selects order history in the "My Account" block, the messages are displayed when they click on "details" in the order history table. This lead me to look at the code in order-details.tpl that displays the data on the screen. Below is that code that I tried to paste in the invoice.tpl file, but it didn't work. Any ideas how to make the messages display in the pdf invoice? {if count($messages)} <h3>{l s='Messages'}</h3> <div class="table_block"> <table class="detail_step_by_step std"> <thead> <tr> <th class="first_item" style="width:150px;">{l s='From'}</th> <th class="last_item">{l s='Message'}</th> </tr> </thead> <tbody> {foreach from=$messages item=message name="messageList"} <tr class="{if $smarty.foreach.messageList.first}first_item{elseif $smarty.foreach.messageList.last}last_item{/if} {if $smarty.foreach.messageList.index % 2}alternate_item{else}item{/if}"> <td> {if isset($message.elastname) && $message.elastname} {$message.efirstname|escape:'htmlall':'UTF-8'} {$message.elastname|escape:'htmlall':'UTF-8'} {elseif $message.clastname} {$message.cfirstname|escape:'htmlall':'UTF-8'} {$message.clastname|escape:'htmlall':'UTF-8'} {else} <b>{$shop_name|escape:'htmlall':'UTF-8'}</b> {/if} <br /> {dateFormat date=$message.date_add full=1} </td> <td>{$message.message|escape:'htmlall':'UTF-8'|nl2br}</td> </tr> {/foreach} </tbody> </table> </div> {/if} The solution: 1. Override the HTMLTemplateInvoice.php using the code below to place the customer messages in Smarty. This will lookup the messages, place assign them into smarty, and then return the standard invoice getContent. The file should be placed in the override/classes/pdf directory. <?php /* * Override for 1.5.4.1 HTMLTemplateInvoice.php to get order messages so they can be displayed in pdf invoice */ class HTMLTemplateInvoice extends HTMLTemplateInvoiceCore { public function getContent() { $this->smarty->assign(array( 'order' => $this->order, 'messages' => CustomerMessage::getMessagesByOrderId((int)($this->order->id), false), )); return parent::getContent(); } } 2. Insert the following code in the theme/pdf/invoice.tpl file. The location depends where you want the comments to display. For my invoice the code was inserted just before </table> <!-- / PRODUCTS TAB --> so the comments were displayed as the last item after the other sections of the invoice. <!-- / CUSTOMER MESSAGES --> <tbody> {if $messages} <b>Order Messages</b> {foreach from=$messages item=message name="messageList"} <tr class="{if $smarty.foreach.messageList.first}first_item{elseif $smarty.foreach.messageList.last}last_item{/if} {if $smarty.foreach.messageList.index % 2}alternate_item{else}item{/if}"> <hr><td> {if isset($message.elastname) && $message.elastname} {$message.efirstname|escape:'htmlall':'UTF-8'} {$message.elastname|escape:'htmlall':'UTF-8'} {elseif $message.clastname} {$message.cfirstname|escape:'htmlall':'UTF-8'} {$message.clastname|escape:'htmlall':'UTF-8'} {else} <b>{$shop_name|escape:'htmlall':'UTF-8'}</b> {/if} <br /> {dateFormat date=$message.date_add full=1} </td> <td>{$message.message|escape:'htmlall':'UTF-8'|nl2br}</td> </tr> {/foreach} {/if} </tbody> <!-- / CUSTOMER MESSAGES --> Edited July 9, 2013 by Rhapsody (see edit history) 6 Link to comment Share on other sites More sharing options...
player.c64 Posted July 1, 2013 Share Posted July 1, 2013 Does anybody know how to add customer TAX ID ? Link to comment Share on other sites More sharing options...
lucascarmona Posted July 4, 2013 Share Posted July 4, 2013 Hi!! Thanks for the useful information!! I want to add an image to each product. Does anybody share how to do it? Thanks!!!! Link to comment Share on other sites More sharing options...
Stefand Posted July 8, 2013 Share Posted July 8, 2013 Is there a way to show the attributes below the product name? Or is there a smarty available to show the attributes separate? Right now in invoice.tpl it's using: {$order_detail.product_name} and the product name and attributes are all in 1 line (very ugly) Link to comment Share on other sites More sharing options...
Rhapsody Posted July 8, 2013 Share Posted July 8, 2013 Is there a way to show the attributes below the product name? Or is there a smarty available to show the attributes separate? Right now in invoice.tpl it's using: {$order_detail.product_name} and the product name and attributes are all in 1 line (very ugly) see my post #78 in this thread with the solution. Link to comment Share on other sites More sharing options...
sooroos Posted July 16, 2013 Share Posted July 16, 2013 Hi guys, Does anyone know how to display the time next to date in the default invoice? i tried to change {dateFormat date=$order->date_add full=0} into {dateFormat date=$order->date_add|date_format:"%d-%m-%Y %H:%M"} in invoice.tpl but it is not working Link to comment Share on other sites More sharing options...
Bejo Posted July 21, 2013 Share Posted July 21, 2013 (edited) How do i rename tax excl. top of colom header-> Unit Price (Tax Excl.) colum title. to be only Unit Price thx you all Edited July 21, 2013 by Bejo (see edit history) Link to comment Share on other sites More sharing options...
Bejo Posted July 22, 2013 Share Posted July 22, 2013 please help how to rename page title of pdf invocie? i want to remove bold text -> Total (Tax Excl.) & Unit Price(Tax Excl.) Link to comment Share on other sites More sharing options...
eleazar Posted July 22, 2013 Share Posted July 22, 2013 Hi Bejo, either in the /pdf/invoice.tpl itself or in /pdf/translations/<yourlanguage>.php. Link to comment Share on other sites More sharing options...
tuk66 Posted July 24, 2013 Share Posted July 24, 2013 (edited) Hi guys, Does anyone know how to display the time next to date in the default invoice? i tried to change {dateFormat date=$order->date_add full=0} into {dateFormat date=$order->date_add|date_format:"%d-%m-%Y %H:%M"} in invoice.tpl but it is not working Have you tried? {dateFormat date=$order->date_add full=1} with full=1 Edited July 24, 2013 by tuk66 (see edit history) Link to comment Share on other sites More sharing options...
sooroos Posted July 24, 2013 Share Posted July 24, 2013 Have you tried? {dateFormat date=$order->date_add full=1} with full=1 hi, i tried but doesnt work Link to comment Share on other sites More sharing options...
tuk66 Posted July 25, 2013 Share Posted July 25, 2013 displayDate() function in Tools.php (PrestaShop v1.5.4.1) says that "full" dates are displayed according to "Date format (full)" format under every language. Link to comment Share on other sites More sharing options...
eleazar Posted July 29, 2013 Share Posted July 29, 2013 That was the first thing too I thought of, but sooroos is right. This 'full=1' statement doesn't work! Link to comment Share on other sites More sharing options...
lgisrael Posted August 1, 2013 Share Posted August 1, 2013 any idea how to use this pdf generator with Hebrew font? I get ???????? ????????. Link to comment Share on other sites More sharing options...
tuk66 Posted August 1, 2013 Share Posted August 1, 2013 Out of the box? Immediately, without extra work? The M4 PDF Extensions module can do that. Link to comment Share on other sites More sharing options...
rgangwani Posted August 14, 2013 Share Posted August 14, 2013 how can I change {$invoice_address} and {$delivery_address} format. Company name (bold) or font size 18 firstname lastname (small) address1, address2 city, country actually I need this format on every document I was Successful in doing that by Editing Line 25 : <div style="font-size: 8pt; color: #444"> to <div style="font-size: 12pt; color: #444"> But this not only changed the font of the address but also the font of prices Link to comment Share on other sites More sharing options...
Vank Posted August 28, 2013 Share Posted August 28, 2013 (edited) Nice tutorial. I'm trying to apply changes given in this post by Supremacy2k, but I'm stuck at the invoice information at the top right of the page. First I would like to remove the word "Invoice" before the "#" (already translated it), to leave just the number, while adding the line "Invoice number:" to the previous <td>. And another issue is right below, the payment method is not showing. In my pdf shows blank. Any solution? help? idea? it would be awesome and save me tons of work. Yes of course I'm not programmer, only designer. Thanks! -- I edit to add that I was testing with an old order, after testing with newer orders it is working ok. Don't know why that difference. But now is working ok. Dismiss my question Edited August 29, 2013 by Vank (see edit history) Link to comment Share on other sites More sharing options...
Ray UK Posted September 6, 2013 Share Posted September 6, 2013 Vank, in invoice.tpl, change the code that displays the order number to the following <tr> <td style="width: 50%; text-align: right">Invoice Number :</td> <td style="text-align: left">{$title|replace:'Invoice #':'':'htmlall':'UTF-8'}</td> </tr> and notice that between Invoice and the # there are 2 spaces... this caused me some headaches too :/ Link to comment Share on other sites More sharing options...
Ray UK Posted September 6, 2013 Share Posted September 6, 2013 Im having trouble getting the customer messages to show on the invoice. I have followed the instructions from Rhapsody but they still don't show. If I comment out the {if $messages} and {/if} then the "Order Messages" does show on the invoice, so that code is in the right place... but no comments show. Im assuming these messages are the "Special instructions" the customer can leave during checkout. I have cleared smart cache, forced compile and even added the code inside of the main HTMLTemplateInvoice.php file. Any help is appreciated. Ray Link to comment Share on other sites More sharing options...
Vank Posted September 6, 2013 Share Posted September 6, 2013 MerseyRay, thanks for the help, but seems is not working. I replaced the complete <tr> for the code you just posted, and below is what I get (I'm working on pdf from the theme's folder) It is very weird, but anything I try on that line is not changed, but everything else does. About the messages from the customers, I also applied the change by Rhapsody, but no results. Link to comment Share on other sites More sharing options...
Ray UK Posted September 6, 2013 Share Posted September 6, 2013 (edited) Vank, try the following.... <tr> <td style="width: 50%; text-align: right">Invoice Number :</td> <td style="text-align: left">{$title|replace:'Invoice':'':'htmlall':'UTF-8'}</td> </tr> (just Invoice, without spaces and #) See if that removes the word "Invoice".. that's where I started The alignment on your image seems a bit off, maybe try pasting my whole code that im using for that table. <table style="width: 100%"> <tr> <td style="width: 50%; text-align: right"> {l s='Order Date:' pdf='true'} : </td> <td style="text-align: left"> {$order->date_add|date_format:"%d-%m-%Y %H:%M"} </td> </tr> <tr> <td style="width: 50%; text-align: right"> Invoice Number : </td> <td style="text-align: left"> {$title|replace:'Invoice #':'':'htmlall':'UTF-8'} </td> </tr> <tr> <td style="width: 50%; text-align: right"> {l s='Order Number:' pdf='true'} : </td> <td style="text-align: left"> {$order->getUniqReference()} </td> </tr> </table> Edited September 6, 2013 by MerseyRay (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now