Jump to content

Shipping template- new variable add


Anns Abz

Recommended Posts

In prestashop 1.7.7.4, i want to add a new variable to the shipped.html template. basicaly a block with user address. something like {user_invoice_address}.
but i didnt find a solution to do this. any hook available to pass this information to the shipped.html template.

Link to comment
Share on other sites

Adding a variable is ok but at first you should tell how are you going to send an email of shipped template? Are you planing to use the default behaviuor of prestashop? Or you need to send this email in a custom way like in a module?

Link to comment
Share on other sites

hi @stifler97 thanks for the reply, yes im planning to use the default behaviour. when an emplyee changing the status from backend[shipped], then this mail is triggering right? so at that point i also want to includes the customer address from the order. currently it doesnot have that variable

Link to comment
Share on other sites

  • 1 year later...

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.

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

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...