Search code examples
phpemailoverridingprestashop-1.7

Prestashop 1.7 add new variables into email total_shipping_tax_excl


I need delivery cost excluded tax in email confirmation. I made changes:

  1. in email translation order_conf I put {total_shipping_tax_excl}

  2. I made override in /override/classes/order/OrderHistory.php

    class OrderHistory extends OrderHistoryCore
    {   
        public function sendEmail($order, $template_vars = false)
        {
            $data = array(
                    '{total_shipping_tax_excl}' => Tools::displayPrice($order->total_shipping_tax_excl, $this->context->currency, false)
                );
            //die (print_r($data,true));    
            if ($template_vars) {
                    $data = array_merge($data, $template_vars);
                }
    
            return parent::sendEmail($order, $data);
        }
    }
    

Override works - if I make die (print_r($data,true)); I can see that proper value is in total_shipping_tax_excl key. Email translation works - I see new string. But when email is sent then I have just {total_shipping_tax_excl} string.

What am I missing?


Solution

  • Enthu was right. First problem was that confirmation email is generated in classes/PaymentModule.php not in /classes/order/OrderHistory.php . Solution is to override original file or wait. I made pull request: https://github.com/PrestaShop/PrestaShop/issues/11396 and chage was accepted so {total_shipping_tax_excl} and {total_shipping_tax_incl} will be in 1.7.6