Hi!
I have a tracking code for my OpenCart site. It's supposed to be put on the checkout page. Here's how the code snippet looks:
<img src="https://track.double.net/track/XXXX/?hash=XXXXXX&value=$TOTAL_VALUE” width="0" height="0">
My problem is replacing $TOTAL_VALUE with the total amount of the current cart (the final sum that the buyer is going to pay). I can clearly see that amount displayed on the cart page and in the header.
Is there not a global variable or something that let's me display this amount?
Thanks for taking the time to read my question. Hopefully this should be a very easy question for someone to answer. I'm very new to OpenCart and MVC so I apologize for such a basic question.
Best Regards,
Albal
This code is meant for the success page, but in the file catalog/controller/checkout/success.php you will notice at the top that the cart gets cleared because the order allready went trough:
Before the line that clears the cart, you can set a variable with the cart value:
Now you have the total for later use. Now, somewhere after the text_message var gets filled in, check if the $order_total is set, and if yes, append your tracking code to the text_message var, like after:
Code: Select all
if (isset($this->session->data['order_id'])) {
$this->cart->clear();
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
unset($this->session->data['guest']);
unset($this->session->data['comment']);
unset($this->session->data['order_id']);
unset($this->session->data['coupon']);
unset($this->session->data['reward']);
unset($this->session->data['voucher']);
unset($this->session->data['vouchers']);
unset($this->session->data['totals']);
}
Code: Select all
$order_total = $this->cart->getTotal();
Code: Select all
if ($this->customer->isLogged()) {
$data['text_message'] = sprintf($this->language->get('text_customer'), $this->url->link('account/account', '', true), $this->url->link('account/order', '', true), $this->url->link('account/download', '', true), $this->url->link('information/contact'));
} else {
$data['text_message'] = sprintf($this->language->get('text_guest'), $this->url->link('information/contact'));
}
Code: Select all
if (isset($order_total) {
$data['text_message'] . = //your tracking code with the $order_total in it;
}
My Extensions - SuperTheme - Opencart templates - Opencart modules
Who is online
Users browsing this forum: No registered users and 17 guests