Jump to content

Edit History

obewanz

obewanz

I know this is a long time after the original question and answers presented then, but for those folks who are STILL running PS 1.6.x Maybe this code will be of assistance (because Prestashop documentation is really useless).

I will not upload the php or template files because at this point, either YOU need to learn how to do these minor modifications, or your developer does, so here are the instructions:

Step 1: Copy your /classes/pdf/HTMLTemplateDeliverySlip.php file to the override folders at /override/classes/pdf/HTMLTemplateDeliverySlip.php
(this is the easiest way to get there if you are new to php object oriented programming)

Step 2: Search for the following line in that file: 

$carrier = new Carrier($this->order->id_carrier);

Step 3: Modify the code to read like this:

/* following line retrieves Customer Order Message */
$customer_message = $this->order->getFirstMessage();
		
$carrier = new Carrier($this->order->id_carrier);

Step 4: Find this block of code:

        $this->smarty->assign(array(
            'order' => $this->order,
            'order_details' => $order_details,
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'order_invoice' => $this->order_invoice,
            'carrier' => $carrier,
            'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY')
        ));

Step 5: Modify the code to read like this:

        $this->smarty->assign(array(
            'order' => $this->order,
            'order_details' => $order_details,
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'order_invoice' => $this->order_invoice,
            'carrier' => $carrier,
            'message' => $customer_message, /* adds customer_message to smarty variables */
            'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY')
        ));

Step 6: Find this block of code (right after the last one):

        $tpls = array(
            'style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')),
            'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')),
            'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')),
            'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')),
            'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab')),
        );

Step 7: Modify the code to read like this:

        $tpls = array(
            'style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')),
            'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')),
            'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')),
            'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')),
            'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab')),
            /* creates a template file to display the customer_message in on the form */
            'message_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.message-tab')),
        );

Save changes and this file is ready to upload to your /override/classes/pdf/ folder AFTER you have completed the following files AND uploaded them. (If you are working on a non-live site, the order that you upload the files doesn't really matter.)

A quick comment: It is absolutely true that you do not need to include the comment lines that describe the changes being made - however, it is my opinion that you should - because somewhere down the line might want to know what you changed, and if you don't work with this code on a daily basis, sometimes even if you do, these comments can provide critical information to refresh your memory why those changes are there, or in the cases of new methods, etc. the parameters and other information expected by the method.

We're not quite finished yet, so moving on...

Step 8: Create a /pdf/delivery-slip.message-tab.tpl file to setup your message display within the pdf template with the following content:

{*
* 2007-2015 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 <contact@prestashop.com>
*  @copyright  2007-2015 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*
*  @author Obewan <obewanz@yahoo.com>
* This is a private modification to prestashop 1.6.x to add the customer order message to the generated pdf delivery slip document.
*
*}
<table id="message-tab" width="100%" cellpadding="4" cellspacing="0">
	<tr>
		<td class="message center small grey bold" width="44%">{l s='Order Message' pdf='true'}</td>
		<td class="message left white" width="56%">
			{$message|escape:'html':'UTF-8'|nl2br}
		</td>
	</tr>
</table>

Comments: There are a number of ways to effect this output, but I felt this not only gave you more information on how to modify pdf generated output for other possible future needs, it also tends to provide a much cleaner solution in the end as it leverages the template system to set this apart from the rest of the form code.

Note: You can ALSO place this same file in your /themes/your-theme-name/pdf/ folder to lessen the possibility of it getting overridden as there is no provision made to create overrides for template files in Prestashop 1.6.x.

Step 9: COPY your /pdf/delivery-slip.tpl file to something like "/pdf/delivery-slip-replaced.tpl (you will use this file to restore your pdf generation template if things go wrong!

Step 10: Search for the following code in the /pdf/delivery-slip.tpl file:

	<tr>
		<td colspan="7" class="left">

			{$payment_tab}

		</td>
		<td colspan="5">&nbsp;</td>
	</tr>

	<!-- Hook -->
	{if isset($HOOK_DISPLAY_PDF)}
	<tr>
		<td colspan="12" height="30">&nbsp;</td>
	</tr>

	<tr>
		<td colspan="2">&nbsp;</td>
		<td colspan="10">
			{$HOOK_DISPLAY_PDF}
		</td>
	</tr>
	{/if}

Step 11: Modify the code to read like this:

	<tr>
		<td colspan="7" class="left">

			{$payment_tab}

		</td>
		<td colspan="5">&nbsp;</td>
	</tr>

	{* -- load message tab and display order message if one exists -- *}
	{if isset($message)} 
	<tr>
		<td colspan="7" class="left">
		{$message_tab}
		</td>
		<td colspan="5">&nbsp;</td>
	</tr>
	{/if}

	<!-- Hook -->
	{if isset($HOOK_DISPLAY_PDF)}
	<tr>
		<td colspan="12" height="30">&nbsp;</td>
	</tr>

	<tr>
		<td colspan="2">&nbsp;</td>
		<td colspan="10">
			{$HOOK_DISPLAY_PDF}
		</td>
	</tr>
	{/if}

Comments: I used the smarty comment method to indicate where the new code insert begins, I could just have easily used html comments as those that already appear in the above code snippet. While I prefer to use the smarty comment method whenever possible, the purpose here was simply to show you something new that you may not be aware of. {* comment *} 

After uploading the files above, the following image depicts the pdf output produced by the above modifications in the standard template:

image.thumb.png.0ec89464ab2faec91c7c0eceec9f8610.png

Note: IF you wanted a separator line between the payment and message elements, you could always add a border between them by either inserting a <tr><td class="separator"></td></tr> as the first row of the table in the /pdf/delivery-slip.message-tabl.tpl file OR by using/adding a css directive like table#message-tab {border-top:1px solid #000;} in the /pdf/delivery-style-tab.tpl file.

Hopefully presenting the answer in this format will not only allow you to add something that SHOULD HAVE ALREADY BEEN IN THE RELEASED CODE of Prestashop 1.6, but it will also help you to learn more about how to modify your own Prestashop site in the future... or maybe even help out a new developer to the codebase.

 

obewanz

obewanz

I know this is a long time after the original question and answers presented then, but for those folks who are STILL running PS 1.6.x Maybe this code will be of assistance (because Prestashop documentation is really useless).

I will not upload the php or template files because at this point, either YOU need to learn how to do these minor modifications, or your developer does, so here are the instructions:

Step 1: Copy your /classes/pdf/HTMLTemplateDeliverySlip.php file to the override folders at /override/classes/pdf/HTMLTemplateDeliverySlip.php
(this is the easiest way to get there if you are new to php object oriented programming)

Step 2: Search for the following line in that file: 

$carrier = new Carrier($this->order->id_carrier);

Step 3: Modify the code to read like this:

/* following line retrieves Customer Order Message */
$customer_message = $this->order->getFirstMessage();
		
$carrier = new Carrier($this->order->id_carrier);

Step 4: Find this block of code:

        $this->smarty->assign(array(
            'order' => $this->order,
            'order_details' => $order_details,
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'order_invoice' => $this->order_invoice,
            'carrier' => $carrier,
            'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY')
        ));

Step 5: Modify the code to read like this:

        $this->smarty->assign(array(
            'order' => $this->order,
            'order_details' => $order_details,
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'order_invoice' => $this->order_invoice,
            'carrier' => $carrier,
            'message' => $customer_message, /* adds customer_message to smarty variables */
            'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY')
        ));

Step 6: Find this block of code (right after the last one):

        $tpls = array(
            'style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')),
            'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')),
            'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')),
            'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')),
            'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab')),
        );

Step 7: Modify the code to read like this:

        $tpls = array(
            'style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')),
            'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')),
            'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')),
            'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')),
            'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab')),
            /* creates a template file to display the customer_message in on the form */
            'message_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.message-tab')),
        );

Save changes and this file is ready to upload to your /override/classes/pdf/ folder AFTER you have completed the following files AND uploaded them. (If you are working on a non-live site, the order that you upload the files doesn't really matter.)

A quick comment: It is absolutely true that you do not need to include the comment lines that describe the changes being made - however, it is my opinion that you should - because somewhere down the line might want to know what you changed, and if you don't work with this code on a daily basis, sometimes even if you do, these comments can provide critical information to refresh your memory why those changes are there, or in the cases of new methods, etc. the parameters and other information expected by the method.

We're not quite finished yet, so moving on...

Step 8: Create a /pdf/delivery-slip.message-tab.tpl file to setup your message display within the pdf template with the following content:

{*
* 2007-2015 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 <contact@prestashop.com>
*  @copyright  2007-2015 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*
*  @author Obewan <obewanz@yahoo.com>
* This is a private modification to prestashop 1.6.x to add the customer order message to the generated pdf delivery slip document.
*
*}
<table id="message-tab" width="100%" cellpadding="4" cellspacing="0">
	<tr>
		<td class="message center small grey bold" width="44%">{l s='Order Message' pdf='true'}</td>
		<td class="message left white" width="56%">
			{$message|escape:'html':'UTF-8'|nl2br}
		</td>
	</tr>
</table>

Comments: There are a number of ways to effect this output, but I felt this not only gave you more information on how to modify pdf generated output for other possible future needs, it also tends to provide a much cleaner solution in the end as it leverages the template system to set this apart from the rest of the form code.

Note: You can ALSO place this same file in your /themes/your-theme-name/pdf/ folder to lessen the possibility of it getting overridden as there is no provision made to create overrides for template files in Prestashop 1.6.x.

Step 9: COPY your /pdf/delivery-slip.tpl file to something like "/pdf/delivery-slip-replaced.tpl (you will use this file to restore your pdf generation template if things go wrong!

Step 10: Search for the following code in the /pdf/delivery-slip.tpl file:

	<tr>
		<td colspan="7" class="left">

			{$payment_tab}

		</td>
		<td colspan="5">&nbsp;</td>
	</tr>

	<!-- Hook -->
	{if isset($HOOK_DISPLAY_PDF)}
	<tr>
		<td colspan="12" height="30">&nbsp;</td>
	</tr>

	<tr>
		<td colspan="2">&nbsp;</td>
		<td colspan="10">
			{$HOOK_DISPLAY_PDF}
		</td>
	</tr>
	{/if}

Step 11: Modify the code to read like this:

	<tr>
		<td colspan="7" class="left">

			{$payment_tab}

		</td>
		<td colspan="5">&nbsp;</td>
	</tr>

	{* -- load message tab and display order message if one exists -- *}
	{if isset($message)} 
	<tr>
		<td colspan="7" class="left">
		{$message_tab}
		</td>
		<td colspan="5">&nbsp;</td>
	</tr>
	{/if}

	<!-- Hook -->
	{if isset($HOOK_DISPLAY_PDF)}
	<tr>
		<td colspan="12" height="30">&nbsp;</td>
	</tr>

	<tr>
		<td colspan="2">&nbsp;</td>
		<td colspan="10">
			{$HOOK_DISPLAY_PDF}
		</td>
	</tr>
	{/if}

Comments: I used the smarty comment method to indicate where the new code insert begins, I could just have easily used html comments as those that already appear in the above code snippet. While I prefer to use the smarty comment method whenever possible, the purpose here was simply to show you something new that you may not be aware of. {* comment *} 

After uploading the files above, the following image depicts the pdf output produced by the above modifications in the standard template:

image.thumb.png.0ec89464ab2faec91c7c0eceec9f8610.png

Note: IF you wanted a separator line between the payment and message elements, you could always add a border between them by either inserting a <tr><td class="separator"></td></tr> as the first row of the table in the /pdf/delivery-slip.message-tabl.tpl file OR by using/adding a css directive like table#message-tab {border-top:1px solid #000;} in the /pdf/delivery-style-tab.tpl file.

Hopefully this presenting the answer in this format will not only allow you to add something that SHOULD HAVE ALREADY BEEN IN THE RELEASED CODE of Prestashop 1.6, but it will also help you to learn more about how to modify your own Prestashop site in the future... or maybe even help out a new developer to the codebase.

 

obewanz

obewanz

I know this is a long time after the original question and answers presented then, but for those folks who are STILL running PS 1.6.x Maybe this code will be of assistance (because Prestashop documentation is really useless).

I will not upload the php or template files because at this point, either YOU need to learn how to do these minor modifications, or your developer does, so here are the instructions:

Step 1: Copy your /classes/pdf/HTMLTemplateDeliverySlip.php file to the override folders at /override/classes/pdf/HTMLTemplateDeliverySlip.php
(this is the easiest way to get there if you are new to php object oriented programming)

Step 2: Search for the following line in that file: 

$carrier = new Carrier($this->order->id_carrier);

Step 3: Modify the code to read like this:

/* following line retrieves Customer Order Message */
$customer_message = $this->order->getFirstMessage();
		
$carrier = new Carrier($this->order->id_carrier);

Step 4: Find this block of code:

        $this->smarty->assign(array(
            'order' => $this->order,
            'order_details' => $order_details,
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'order_invoice' => $this->order_invoice,
            'carrier' => $carrier,
            'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY')
        ));

Step 5: Modify the code to read like this:

        $this->smarty->assign(array(
            'order' => $this->order,
            'order_details' => $order_details,
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'order_invoice' => $this->order_invoice,
            'carrier' => $carrier,
            'message' => $customer_message, /* adds customer_message to smarty variables */
            'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY')
        ));

Step 6: Find this block of code (right after the last one):

        $tpls = array(
            'style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')),
            'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')),
            'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')),
            'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')),
            'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab')),
        );

Step 7: Modify the code to read like this:

        $tpls = array(
            'style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')),
            'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')),
            'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')),
            'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')),
            'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab')),
            /* creates a template file to display the customer_message in on the form */
            'message_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.message-tab')),
        );

Save changes and this file is ready to upload to your /override/classes/pdf/ folder AFTER you have completed the following files AND uploaded them. (If you are working on a non-live site, the order that you upload the files doesn't really matter.)

A quick comment: It is absolutely true that you do not need to include the comment lines that describe the changes being made - however, it is my opinion that you should - because somewhere down the line might want to know what you changed, and if you don't work with this code on a daily basis, sometimes even if you do, these comments can provide critical information to refresh your memory why those changes are there, or in the cases of new methods, etc. the parameters and other information expected by the method.

We're not quite finished yet, so moving on...

Step 8: Create a /pdf/delivery-slip.message-tab.tpl file to setup your message display within the pdf template with the following content:

{*
* 2007-2015 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 <contact@prestashop.com>
*  @copyright  2007-2015 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*
*  @author Obewan <obewanz@yahoo.com>
* This is a private modification to prestashop 1.6.x to add the customer order message to the generated pdf delivery slip document.
*
*}
<table id="message-tab" width="100%" cellpadding="4" cellspacing="0">
	<tr>
		<td class="message center small grey bold" width="44%">{l s='Order Message' pdf='true'}</td>
		<td class="message left white" width="56%">
			{$message|escape:'html':'UTF-8'|nl2br}
		</td>
	</tr>
</table>

Comments: There are a number of ways to effect this output, but I felt this not only gave you more information on how to modify pdf generated output for other possible future needs, it also tends to provide a much cleaner solution in the end as it leverages the template system to set this apart from the rest of the form code.

Note: You can ALSO place this same file in your /themes/your-theme-name/pdf/ folder to lessen the possibility of it getting overridden as there is no provision made to create overrides for template files in Prestashop 1.6.x.

Step 9: COPY your /pdf/delivery-slip.tpl file to something like "/pdf/delivery-slip-replaced.tpl (you will use this file to restore your pdf generation template if things go wrong!

Step 10: Search for the following code in the /pdf/delivery-slip.tpl file:

	<tr>
		<td colspan="7" class="left">

			{$payment_tab}

		</td>
		<td colspan="5">&nbsp;</td>
	</tr>

	<!-- Hook -->
	{if isset($HOOK_DISPLAY_PDF)}
	<tr>
		<td colspan="12" height="30">&nbsp;</td>
	</tr>

	<tr>
		<td colspan="2">&nbsp;</td>
		<td colspan="10">
			{$HOOK_DISPLAY_PDF}
		</td>
	</tr>
	{/if}

Step 11: Modify the code to read like this:

	<tr>
		<td colspan="7" class="left">

			{$payment_tab}

		</td>
		<td colspan="5">&nbsp;</td>
	</tr>

	{* -- load message tab and display order message if one exists -- *}
	{if isset($message)} 
	<tr>
		<td colspan="7" class="left">
		{$message_tab}
		</td>
		<td colspan="5">&nbsp;</td>
	</tr>
	{/if}

	<!-- Hook -->
	{if isset($HOOK_DISPLAY_PDF)}
	<tr>
		<td colspan="12" height="30">&nbsp;</td>
	</tr>

	<tr>
		<td colspan="2">&nbsp;</td>
		<td colspan="10">
			{$HOOK_DISPLAY_PDF}
		</td>
	</tr>
	{/if}

The following image is a sample pdf output produced by the above modifications:

image.thumb.png.0ec89464ab2faec91c7c0eceec9f8610.png

 

Hopefully this will not only allow you to add something that SHOULD HAVE ALREADY BEEN IN THE RELEASED CODE of Prestashop 1.6, but it will also help you to learn more about how to modify your own Prestashop site in the future... or maybe even help a new developer to the codebase.

 

obewanz

obewanz

I know this is a long time after the original question and answers presented then, but for those folks who are STILL running PS 1.6.x Maybe this code will be of assistance (because Prestashop documentation is really useless).

I will not upload the php or template files because at this point, either YOU need to learn how to do these minor modifications, or your developer does, so here are the instructions:

Step 1: Copy your /classes/pdf/HTMLTemplateDeliverySlip.php file to the override folders at /override/classes/pdf/HTMLTemplateDeliverySlip.php
(this is the easiest way to get there if you are new to php object oriented programming)

Step 2: Search for the following line in that file: 

$carrier = new Carrier($this->order->id_carrier);

Step 3: Modify the code to read like this:

/* following line retrieves Customer Order Message */
$customer_message = $this->order->getFirstMessage();
		
$carrier = new Carrier($this->order->id_carrier);

Step 4: Find this block of code:

        $this->smarty->assign(array(
            'order' => $this->order,
            'order_details' => $order_details,
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'order_invoice' => $this->order_invoice,
            'carrier' => $carrier,
            'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY')
        ));

Step 5: Modify the code to read like this:

        $this->smarty->assign(array(
            'order' => $this->order,
            'order_details' => $order_details,
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'order_invoice' => $this->order_invoice,
            'carrier' => $carrier,
            'message' => $customer_message, /* adds customer_message to smarty variables */
            'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY')
        ));

Step 6: Find this block of code (right after the last one):

        $tpls = array(
            'style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')),
            'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')),
            'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')),
            'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')),
            'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab')),
        );

Step 7: Modify the code to read like this:

        $tpls = array(
            'style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')),
            'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')),
            'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')),
            'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')),
            'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab')),
            /* creates a template file to display the customer_message in on the form */
            'message_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.message-tab')),
        );

Save changes and this file is ready to upload to your /override/classes/pdf/ folder AFTER you have completed the following files AND uploaded them. (If you are working on a non-live site, the order that you upload the files doesn't really matter.)

A quick comment: It is absolutely true that you do not need to include the comment lines that describe the changes being made - however, it is my opinion that you should - because somewhere down the line might want to know what you changed, and if you don't work with this code on a daily basis, sometimes even if you do, these comments can provide critical information to refresh your memory why those changes are there, or in the cases of new methods, etc. the parameters and other information expected by the method.

We're not quite finished yet, so moving on...

Step 8: Create a /pdf/delivery-slip.message-tab.tpl file to setup your message display within the pdf template with the following content:

{*
* 2007-2015 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 <contact@prestashop.com>
*  @copyright  2007-2015 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*
*  @author Obewan <obewanz@yahoo.com>
* This is a private modification to prestashop 1.6.x to add the customer order message to the generated pdf delivery slip document.
*
*}
<table id="message-tab" width="100%" cellpadding="4" cellspacing="0">
	<tr>
		<td class="message center small grey bold" width="44%">{l s='Order Message' pdf='true'}</td>
		<td class="message left white" width="56%">
			{$message|escape:'html':'UTF-8'|nl2br}
		</td>
	</tr>
</table>

Comments: There are a number of ways to effect this output, but I felt this not only gave you more information on how to modify pdf generated output for other possible future needs, it also tends to provide a much cleaner solution in the end as it leverages the template system to set this apart from the rest of the form code.

Note: You can ALSO place this same file in your /themes/your-theme-name/pdf/ folder to lessen the possibility of it getting overridden as there is no provision made to create overrides for template files in Prestashop 1.6.x.

Step 9: COPY your /pdf/delivery-slip.tpl file to something like "/pdf/delivery-slip-replaced.tpl (you will use this file to restore your pdf generation template if things go wrong!

Step 10: Search for the following code in that file:

	<tr>
		<td colspan="7" class="left">

			{$payment_tab}

		</td>
		<td colspan="5">&nbsp;</td>
	</tr>

	<!-- Hook -->
	{if isset($HOOK_DISPLAY_PDF)}
	<tr>
		<td colspan="12" height="30">&nbsp;</td>
	</tr>

	<tr>
		<td colspan="2">&nbsp;</td>
		<td colspan="10">
			{$HOOK_DISPLAY_PDF}
		</td>
	</tr>
	{/if}

Step 11: Modify the code to read like this:

	<tr>
		<td colspan="7" class="left">

			{$payment_tab}

		</td>
		<td colspan="5">&nbsp;</td>
	</tr>

	{* -- load message tab and display order message if one exists -- *}
	{if isset($message)} 
	<tr>
		<td colspan="7" class="left">
		{$message_tab}
		</td>
		<td colspan="5">&nbsp;</td>
	</tr>
	{/if}

	<!-- Hook -->
	{if isset($HOOK_DISPLAY_PDF)}
	<tr>
		<td colspan="12" height="30">&nbsp;</td>
	</tr>

	<tr>
		<td colspan="2">&nbsp;</td>
		<td colspan="10">
			{$HOOK_DISPLAY_PDF}
		</td>
	</tr>
	{/if}

The following image is a sample pdf output produced by the above modifications:

image.thumb.png.0ec89464ab2faec91c7c0eceec9f8610.png

 

Hopefully this will not only allow you to add something that SHOULD HAVE ALREADY BEEN IN THE RELEASED CODE of Prestashop 1.6, but it will also help you to learn more about how to modify your own Prestashop site in the future... or maybe even help a new developer to the codebase.

 

obewanz

obewanz

I know this is a long time after the original question and answers presented then, but for those folks who are STILL running PS 1.6.x Maybe this code will be of assistance (because Prestashop documentation is really useless).

I will not upload the php or template files because at this point, either YOU need to learn how to do these minor modifications, or your developer does, so here are the instructions:

Step 1: Copy your /classes/pdf/HTMLTemplateDeliverySlip.php file to the override folders at /override/classes/pdf/HTMLTemplateDeliverySlip.php
(this is the easiest way to get there if you are new to php object oriented programming)

Step 2: Search for the following line in that file: 

$carrier = new Carrier($this->order->id_carrier);

Step 3: Modify the code to read like this:

/* following line retrieves Customer Order Message */
$customer_message = $this->order->getFirstMessage();
		
$carrier = new Carrier($this->order->id_carrier);

Step 4: Find this block of code:

        $this->smarty->assign(array(
            'order' => $this->order,
            'order_details' => $order_details,
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'order_invoice' => $this->order_invoice,
            'carrier' => $carrier,
            'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY')
        ));

Step 5: Modify the code to read like this:

        $this->smarty->assign(array(
            'order' => $this->order,
            'order_details' => $order_details,
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'order_invoice' => $this->order_invoice,
            'carrier' => $carrier,
            'message' => $customer_message, /* adds customer_message to smarty variables */
            'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY')
        ));

Step 6: Find this block of code (right after the last one):

        $tpls = array(
            'style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')),
            'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')),
            'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')),
            'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')),
            'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab')),
        );

Step 7: Modify the code to read like this:

        $tpls = array(
            'style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')),
            'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')),
            'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')),
            'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')),
            'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab')),
            /* creates a template file to display the customer_message in on the form */
            'message_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.message-tab')),
        );

Save changes and this file is ready to upload to your /override/classes/pdf/ folder AFTER you have completed the following files AND uploaded them. (If you are working on a non-live site, the order that you upload the files doesn't really matter.)

A quick comment: It is absolutely true that you do not need to include the comment lines that describe the changes being made - however, it is my opinion that you should - because somewhere down the line might want to know what you changed, and if you don't work with this code on a daily basis, sometimes even if you do, these comments can provide critical information to refresh your memory why those changes are there, or in the cases of new methods, etc. the parameters and other information expected by the method.

We're not quite finished yet, so moving on...

Step 8: Create a /pdf/delivery-slip.message-tab.tpl file to setup your message display within the pdf template with the following content:

{*
* 2007-2015 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 <contact@prestashop.com>
*  @copyright  2007-2015 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*
*  @author Obewan <obewanz@yahoo.com>
* This is a private modification to prestashop 1.6.x to add the customer order message to the delivery slip to the generated pdf document.
*
*}
<table id="message-tab" width="100%" cellpadding="4" cellspacing="0">
	<tr>
		<td class="message center small grey bold" width="44%">{l s='Order Message' pdf='true'}</td>
		<td class="message left white" width="56%">
			{$message|escape:'html':'UTF-8'|nl2br}
		</td>
	</tr>
</table>

Comments: There are a number of ways to effect this output, but I felt this not only gave you more information on how to modify pdf generated output for other possible future needs, it also tends to provide a much cleaner solution in the end as it leverages the template system to set this apart from the rest of the form code.

Note: You can ALSO place this same file in your /themes/your-theme-name/pdf/ folder to lessen the possibility of it getting overridden as there is no provision made to create overrides for template files in Prestashop 1.6.x.

Step 9: COPY your /pdf/delivery-slip.tpl file to something like "/pdf/delivery-slip-replaced.tpl (you will use this file to restore your pdf generation template if things go wrong!

Step 10: Search for the following code in that file:

	<tr>
		<td colspan="7" class="left">

			{$payment_tab}

		</td>
		<td colspan="5">&nbsp;</td>
	</tr>

	<!-- Hook -->
	{if isset($HOOK_DISPLAY_PDF)}
	<tr>
		<td colspan="12" height="30">&nbsp;</td>
	</tr>

	<tr>
		<td colspan="2">&nbsp;</td>
		<td colspan="10">
			{$HOOK_DISPLAY_PDF}
		</td>
	</tr>
	{/if}

Step 11: Modify the code to read like this:

	<tr>
		<td colspan="7" class="left">

			{$payment_tab}

		</td>
		<td colspan="5">&nbsp;</td>
	</tr>

	{* -- load message tab and display order message if one exists -- *}
	{if isset($message)} 
	<tr>
		<td colspan="7" class="left">
		{$message_tab}
		</td>
		<td colspan="5">&nbsp;</td>
	</tr>
	{/if}

	<!-- Hook -->
	{if isset($HOOK_DISPLAY_PDF)}
	<tr>
		<td colspan="12" height="30">&nbsp;</td>
	</tr>

	<tr>
		<td colspan="2">&nbsp;</td>
		<td colspan="10">
			{$HOOK_DISPLAY_PDF}
		</td>
	</tr>
	{/if}

The following image is a sample pdf output produced by the above modifications:

image.thumb.png.0ec89464ab2faec91c7c0eceec9f8610.png

 

Hopefully this will not only allow you to add something that SHOULD HAVE ALREADY BEEN IN THE RELEASED CODE of Prestashop 1.6, but it will also help you to learn more about how to modify your own Prestashop site in the future... or maybe even help a new developer to the codebase.

 

obewanz

obewanz

I know this is a long time after the original question and answers presented then, but for those folks who are STILL running PS 1.6.x Maybe this code will be of assistance (because Prestashop documentation is really useless).

I will not upload the php or template files because at this point, either YOU need to learn how to do these minor modifications, or your developer does, so here are the instructions:

Step 1: Copy your /classes/pdf/HTMLTemplateDeliverySlip.php file to the override folders at /override/classes/pdf/HTMLTemplateDeliverySlip.php
(this is the easiest way to get there if you are new to php object oriented programming)

Step 2: Search for the following line in that file: 

$carrier = new Carrier($this->order->id_carrier);

Step 3: Modify the code to read like this:

/* following line retrieves Customer Order Message */
$customer_message = $this->order->getFirstMessage();
		
$carrier = new Carrier($this->order->id_carrier);

Step 4: Find this block of code:

        $this->smarty->assign(array(
            'order' => $this->order,
            'order_details' => $order_details,
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'order_invoice' => $this->order_invoice,
            'carrier' => $carrier,
            'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY')
        ));

Step 5: Modify the code to read like this:

        $this->smarty->assign(array(
            'order' => $this->order,
            'order_details' => $order_details,
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'order_invoice' => $this->order_invoice,
            'carrier' => $carrier,
            'message' => $customer_message, /* adds customer_message to smarty variables */
            'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY')
        ));

Step 6: Find this block of code (right after the last one):

        $tpls = array(
            'style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')),
            'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')),
            'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')),
            'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')),
            'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab')),
        );

Step 7: Modify the code to read like this:

        $tpls = array(
            'style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')),
            'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')),
            'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')),
            'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')),
            'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab')),
            /* creates a template file to display the customer_message in on the form */
            'message_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.message-tab')),
        );

Save changes and this file is ready to upload to your /override/classes/pdf/ folder.

A quick comment: It is absolutely true that you do not need to include the comment lines that describe the changes being made - however, it is my opinion that you should because somewhere down the line might want to know what you changed, and if you don't work with this code on a daily basis (sometimes even if you do) these comments can provide critical information to refresh your memory why those changes are there, or in the cases of new methods, etc. the parameters and other information expected by the method.

So we're not quite finished yet, so moving on...

Step 8: Create a /pdf/delivery-slip.message-tab.tpl file to setup your message display within the pdf template with the following content:

{*
* 2007-2015 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 <contact@prestashop.com>
*  @copyright  2007-2015 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*
*  @author Obewan <obewanz@yahoo.com>
* This is a private modification to prestashop 1.6.x to add the customer order message to the delivery slip to the generated pdf document.
*
*}
<table id="message-tab" width="100%" cellpadding="4" cellspacing="0">
	<tr>
		<td class="message center small grey bold" width="44%">{l s='Order Message' pdf='true'}</td>
		<td class="message left white" width="56%">
			{$message|escape:'html':'UTF-8'|nl2br}
		</td>
	</tr>
</table>

Comments: There are a number of ways to effect this output, but I felt this not only gave you more information on how to modify pdf generated output for other possible future needs, it also tends to provide a much cleaner solution in the end as it leverages the template system to set this apart from the rest of the form code.

Note: You can ALSO place this same file in your /themes/your-theme-name/pdf/ folder to lessen the possibility of it getting overridden as there is no provision made to create overrides for template files in Prestashop 1.6.x.

Step 9: COPY your /pdf/delivery-slip.tpl file to something like "/pdf/delivery-slip-replaced.tpl (you will use this file to restore your pdf generation template if things go wrong!

Step 10: Search for the following code in that file:

	<tr>
		<td colspan="7" class="left">

			{$payment_tab}

		</td>
		<td colspan="5">&nbsp;</td>
	</tr>

	<!-- Hook -->
	{if isset($HOOK_DISPLAY_PDF)}
	<tr>
		<td colspan="12" height="30">&nbsp;</td>
	</tr>

	<tr>
		<td colspan="2">&nbsp;</td>
		<td colspan="10">
			{$HOOK_DISPLAY_PDF}
		</td>
	</tr>
	{/if}

Step 11: Modify the code to read like this:

	<tr>
		<td colspan="7" class="left">

			{$payment_tab}

		</td>
		<td colspan="5">&nbsp;</td>
	</tr>

	{* -- load message tab and display order message if one exists -- *}
	{if isset($message)} 
	<tr>
		<td colspan="7" class="left">
		{$message_tab}
		</td>
		<td colspan="5">&nbsp;</td>
	</tr>
	{/if}

	<!-- Hook -->
	{if isset($HOOK_DISPLAY_PDF)}
	<tr>
		<td colspan="12" height="30">&nbsp;</td>
	</tr>

	<tr>
		<td colspan="2">&nbsp;</td>
		<td colspan="10">
			{$HOOK_DISPLAY_PDF}
		</td>
	</tr>
	{/if}

The following image is a sample pdf output produced by the above modifications:

image.thumb.png.0ec89464ab2faec91c7c0eceec9f8610.png

 

Hopefully this will not only allow you to add something that SHOULD HAVE ALREADY BEEN IN THE RELEASED CODE of Prestashop 1.6, but it will also help you to learn more about how to modify your own Prestashop site in the future... or maybe even help a new developer to the codebase.

 

×
×
  • Create New...