Categories: Adword Conversion Tracking

Order total value and order id in Opencart

OpenCart is designed with feature rich, easy to use, search engine friendly and with a visually appealing interface.

There is vast collection of extensions to fulfill basic and frequently required operations. But main problem is that most of the extensions are of paid version, and most of the developers and client don’t want to pay for some extensions.

Here I have mention some of the frequently asked question by many developers and clients, i.e :

  • How to add total value  and order id in order confirmation page of opencart?

  • How to add conversion tracking code in opencart with conversion code?

So here, I have mention some easy solution of above problems, for  that you don’t have to pay anything to anyone.

Just get FTP access of your website and then keep a backup site or minimum those pages which you are going to upload.

The problem here is that on success page all the order data is already unset (deleted) from session variables. That is why we won’t be able to show those order details directly on the order confirmation page.

Look into catalog/controller/checkout/success.php and change the beginning of the index() function, code will look like :

public function index() {
    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']);
    }   

    $this->language->load('checkout/success');

Now you have to add few lines of code in the above code

public function index() {
    $this->data['order_id'] = 0; // <-- NEW LINE $this->data['total'] = 0; // <-- NEW LINE if (isset($this->session->data['order_id'])) {
        $this->data['order_id'] = $this->session->data['order_id']; // <-- NEW LINE $this->data['total'] = $this->cart->getTotal(); // <-- NEW LINE $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']);
    }   

    $this->language->load('checkout/success');

Now you have the order_id and cart’s total values stored in template variables, so just use them in your success.tpl ( catalog/view/theme/[YOUR THEME]/template/common/success.tpl).

<!--?php if($order_id) { ?-->
Your order id is: <!--?php echo $order_id; ?-->
Total Amount is:<!--?php echo $total; ?-->
<!--?php } ?-->

Note : It is working fine for me, there might be some issue as per version or customization of opencart. If you are facing any problem, you can put some word to us.

Notes On Click

Share
Published by
Notes On Click
Tags: adwords dynamic remarketingEcommerce trackinggoogle analyticsmagento conversion trackingopencartopentcart conversion trackingshopify eCommerce settingshopify enhance eCommerce setting

Recent Posts

  • Adword Conversion Tracking
  • Google Adwords Remarketing

Conversion and Remaketing code in BigCommerce

In this blog, you will see how to add Adwords Conversion Tracking and Remarkeing Code in BigCommerce.BigCommerce is one of…

7 years ago
  • Google Analytics and Ecommerce Tracking

Ecommerce Tracking in OpenCart 2.3

Around 6 months back, I had published an article on “How to add GA e-commerce tracking in Opencart“. I am really thankful…

8 years ago
  • Google Analytics and Ecommerce Tracking

Google Analytics Definition and Common Terms

 If you have gone through our previous blog about Google Analytics, you might have sound understanding about Google Analytics and how it…

8 years ago
  • Google Analytics and Ecommerce Tracking

What is Google Analytics and it’s Features?

Do you want to know more about your visitors and how your content is performing?​ Whether you run a website…

8 years ago
  • Google Analytics and Ecommerce Tracking

How to Add Google Analytics in BigCommerce

In this blog, you will see how to add Google Analytics and E-commerce Tracking Code  in BigCommerce. BigCommerce is one of the…

8 years ago
  • Google Analytics and Ecommerce Tracking

Google Analytics and E-commerce Tracking in Miva Merchant

If you have gone through some of previous blog, you might have seen how to install google analytics, e-commerce tracking…

8 years ago