Jump to content

Reference product on Order-confirmation.tpl


pedluis

Recommended Posts

Hello i'm trying to get some values of the order, specially prices and reference code of the product that the customer bought.

 

I've modified OrderConfirmationControler.php

    public function initContent()
    {
        parent::initContent();

        $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,
                'reference_order' => $this->reference,
                '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->setTemplate(_PS_THEME_DIR_.'order-confirmation.tpl');
	      $order = new Order($this->id_order);
	      $cart = new Cart($order->id_cart);
		    $id_order = $this->id_order;
	      $description=""; 
          foreach ($cart->getProducts() AS $k=>$v)
            {
            $description.=$v['reference'];  
            }       
            
        $description = "['".$description."']";
        $this->context->smarty->assign(array(
        'total_products'=>$order->total_products,
        'description'=>$description,
        'id_order' =>$order->total_products
        ));
        $this->setTemplate(_PS_THEME_DIR_.'order-confirmation.tpl');
    }

And into the file order-confirmation.tpl i put this

<p>{$id_order|string_format:"%.2f"} </p>

<p>{$description}</p>
<p>[{$id_order|string_format:"%.2f"}]</p>
<p>{$total_products}</p>

On my test subdomain everything works, but in my official domain the reference code is not viewing.

I try to find where could be the problem, and it is into the foreach.

 

I don't know if there is any conflict because i'm getting always an empty value.

 

Anyone can help me?

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...