Latest Articles
So far this was never an issue, there were problems with uploading modules via the installer because of the ftp connection but you could allways install ocmods without any issue. However, some .. Read More
People had this issue so many times I thought I would write a bit about it. The  types of issues with opencart's 2.x modification system that I identified so far are: 1. Old Vqmod .. Read More
This small tutorial will show you how to manually add custom links to the default top menu in opencart. If you dont want to go trough all the hustle and would like to be able to completly customize.. Read More
To enable seo urls in opencart navigate in admin to system > settings , edit the store and on the server tab of the store settings you will find "Use SEO urls", set it to yes. So far e.. Read More
All Articles

Add to cart redirect to Cart page or checkout on opencart 1.5.2.

If you want to redirect your customer to cart page or checkout page after he added a product to cart, here is how you do it.

(This applies to opencart 1.5.2.x and 1.5.3.x)

Edit the files: catalog/view/javascript/common.js and catalog/view/theme/yourtheme/template/product/product.tpl and in each file, make the following modification:

Find the code:

if (json['success']) {
$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');



$('html, body').animate({ scrollTop: 0 }, 'slow');

And, if you want to redirect to checkout page, replace it with;

if (json['success']) {

Or, if you want it to redirect to cart page, replace it with:

if (json['success']) {


That is all, I hope you'll enjoy it.

Posted by Flo

26 Comments To "Add to cart redirect to Cart page or checkout on opencart 1.5.2."

vivek On 25 Apr 2016
facing the same issue with open cart 1.5.6 please guide me Reply to this comment
Jitendra Kumar On 26 May 2015
This is realy helpfull for me and also working on opencart Thanks Reply to this comment
sheida On 07 Jul 2015
Hi, Im using opencart 2 but in common.js I cant find this code.There isnt this code in common.js
Giuseppe On 21 Jul 2014
Perfetto funziona molto bene semplice e ben descritto. Molto bene. Bravo. Reply to this comment
Hamad Hassan On 23 Jun 2014
I have add to card button on the main page below the product it didn't redirect but internal add to cart works fine any one can help? Reply to this comment
Stoxx On 19 Jun 2014
Thanks you, this work in Opencart 1.5.6 Reply to this comment
anie On 07 Jun 2014
very good!!!!!!!!!!!!!!! Reply to this comment
hari On 21 May 2014
Simple but very useful code... thank you so much Reply to this comment
SOHEL Talukder On 15 Mar 2014
how change Add to cart redirect to Cart page or checkout on opencart Reply to this comment
Tracey Gordon On 01 Feb 2014
Awesome work. I just realized that I got my template from your store as well. Keep up the great work. Reply to this comment
bram On 31 Dec 2013
It works great although it does not work on internet explorer. It wil redirect you to /category/index.php?route=checkout/cart Reply to this comment

Write a comment

Your Name:

Enter the code in the box below:

Your Comment:
Note: HTML is not translated!