To add a new variable to the shipped.html template in PrestaShop 1.7.7.4, you might need to create a custom module and use a hook to inject the necessary information. Here's a general guide on how you can achieve this:
1. Create a Custom Module:
Create a new directory in your modules folder. For example, customshippinginfo.
Inside this directory, create a file named customshippinginfo.
In customshippinginfo.php, define your module and implement the hookDisplayOrderConfirmation function.
<class CustomShippingInfo extends Module { public function __construct() { $this->name = 'customshippinginfo'; $this->tab = 'front_office_features'; $this->version = '1.0.0'; $this->author = 'Your Name'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Custom Shipping Info'); $this->description = $this->l('Add custom shipping information to order confirmation.'); } public function install() { return parent::install() && $this->registerHook('displayOrderConfirmation'); } public function hookDisplayOrderConfirmation($params) { $this->context->smarty->assign(array( 'userInvoiceAddress' => $this->getUserInvoiceAddress($params['order']), )); return $this->display(__FILE__, 'views/templates/hook/order-confirmation.tpl'); } private function getUserInvoiceAddress($order) { // Add your logic to retrieve the user's invoice address based on the order. // You may use $order object to get customer details. return 'User Invoice Address'; } }
2. Create a Template File:
Create a new directory inside your module directory: customshippinginfo/views/templates/hook/.
Inside this directory, create a file named order-confirmation.tpl.
In order-confirmation.tpl, you can use your new variable like this:
{if isset($userInvoiceAddress)} <div class="user-invoice-address"> {$userInvoiceAddress} </div> {/if}
3. Install and Configure the Module:
Go to your PrestaShop admin panel.
Navigate to Modules and Services > Module Manager.
Look for your module (Custom Shipping Info) and install it.
Once installed, configure any additional settings or preferences in the module configuration page.
Test by placing an order and checking the order confirmation page.