In this tutorial, we will show you how to redirect "Add to cart" button in Opencart version 1.4+, version 1.5+, version 2.0+ and version 3.0+ and take you directly to the shopping cart page.
For Opencart 1.4+ versions
For Opencart 1.4 versions it's easy we can do it through the admin section
In Extensions->Modules under "Cart" you can disable ajax
For Opencart 1.5+ versions
But in O
Open the javascript file at catalog/view/javascript/common.js
Find the code below :
if (json['success']) {
$('#notification').html('
');
$('.attention').fadeIn('slow');
$('#cart_total').html(json['total']);
$('html, body').animate({ scrollTop: 0 }, 'slow');
}
Replace with
if (json['success']) {
window.location.href='index.php?route=checkout/cart';
}
For OpenCart 2.3.0.2+ and Opencart 3.0+ follow following steps:
Find following code at catalog\view\javascript\common.js
var cart = { 'add': function(product_id, quantity) {
Inside that find success method:
success: function(json) { $('.alert, .text-danger').remove();
Just below it add following code:
json['redirect']='index.php?route=checkout/cart';
Now open another file catalog\view\theme\ACTIVETHEME\template\product\product.tpl
Find following code: