Jump to content

Total price in order-confirmation.tpl


TesCZ
 Share

Recommended Posts

  • 2 weeks later...
  • 7 months later...
  • 1 year later...

You have to assign smarty variables in OrderConfirmationController.php as it is done in the initContent() function. 

I had to display total paid and currency iso code because of some FB pixels. 

 

$this->context->smarty->assign(array(
'ordersTotalPaid' => $order->getOrdersTotalPaid(),
'ordersCurrency' => $currency->iso_code
));
 
After inserting this lines into the displayPaymentReturn() function you will be able to reach these variables in your tpl file.
{$ordersTotalPaid}
{$ordersCurrency}

Share this post


Link to post
Share on other sites

  • 1 year later...

in: override/controllers/front/OrderConfirmationController.php

public function initContent()
    {
        parent::initContent();
        $cart = new Cart($this->id_cart, $this->context->language->id);
        $products = $cart->getProducts();
        $order = new Order($this->id_order);

        $this->context->smarty->assign(array(
            'is_guest' => $this->context->customer->is_guest,
            'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(),
            'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn()
        ));

        if ($this->context->customer->is_guest) {
            $this->context->smarty->assign(array(
                'id_order' => $this->id_order,
                'products' => $products,
                'reference_order' => $this->reference,
                'ordersTotalPaid' => $order->getOrdersTotalPaid(),
                'id_order_formatted' => sprintf('#%06d', $this->id_order),
                'email' => $this->context->customer->email
            ));
            /* If guest we clear the cookie for security reason */
            $this->context->customer->mylogout();
        }

        $this->context->smarty->assign(array(
            'id_order' => $this->id_order,
            'products' => $products,
            'ordersTotalPaid' => $order->getOrdersTotalPaid(),
            'reference_order' => $this->reference,
            'id_order_formatted' => sprintf('#%06d', $this->id_order),
            'email' => $this->context->customer->email
        ));

        $this->setTemplate(_PS_THEME_DIR_.'order-confirmation.tpl');
    }

in /themes/theme-name/order-confirmation.tpl

{sprintf("%.2f",$ordersTotalPaid)}

Share this post


Link to post
Share on other sites

  • 3 years later...

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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More