that part is gone in 1.5.x
OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter
today I've spent an hour or so to find a solution on how to redirect a client to the cart page when pressed "add to cart".
I'm using 1.5.0.5v, there is no way to do it from the admin panel like in earlier versions.
I have seen different php based solutions that haven't worked for me, so I came with my own javascript based solution.
The idea is very simple. You just have to append a redirect command to onclick event.
instead of
use
or (not tested yet) if there are no onclick event, just add one with the redirect, or just add the redirect at the end of the addToCart function
I'm using 1.5.0.5v, there is no way to do it from the admin panel like in earlier versions.
I have seen different php based solutions that haven't worked for me, so I came with my own javascript based solution.
The idea is very simple. You just have to append a redirect command to onclick event.
instead of
Code: Select all
<a class="button" onclick="addToCart('73');">
Code: Select all
<a class="button" onclick="addToCart('73');window.location='index.php?route=checkout/cart';">
Working on hebrew rtl opencart 1.5.0.5v http://automoto.co.il
There is a little problem with this method. Sometimes the redirect works faster than the ajax add to cart code, it does adds a product to cart, but when you get to the carts page you don't see the product until you refresh. To solve this you can use setTimeout().
add to common.js function
and instead of
use
add to common.js function
Code: Select all
function RedirectToCart(){
window.location='index.php?route=checkout/cart';
}
Code: Select all
<a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button">
Code: Select all
<a onclick="addToCart('<?php echo $product['product_id']; ?>');setTimeout('RedirectToCart()',2000);" class="button">
Working on hebrew rtl opencart 1.5.0.5v http://automoto.co.il
where is the
located ?
is this in product.tpl ??
Code: Select all
<a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button">
is this in product.tpl ??
I did it for testing only at home page in featured - module/featured.tpl
If you want to use it in all places there are about 5 or more files including product.tpl, you'll just have to look for..
If I gonna use it in my site everywhere, I will post the list of files.
If you want to use it in all places there are about 5 or more files including product.tpl, you'll just have to look for..
If I gonna use it in my site everywhere, I will post the list of files.
Working on hebrew rtl opencart 1.5.0.5v http://automoto.co.il
List of files
./catalog/view/theme/default/template/module/featured.tpl:
./catalog/view/theme/default/template/module/special.tpl:
./catalog/view/theme/default/template/module/bestseller.tpl:
./catalog/view/theme/default/template/module/latest.tpl:
./catalog/view/theme/default/template/product/product.tpl:
./catalog/view/theme/default/template/product/manufacturer_info.tpl:
./catalog/view/theme/default/template/product/special.tpl:
./catalog/view/theme/default/template/product/compare.tpl:
./catalog/view/theme/default/template/product/search.tpl:
./catalog/view/theme/default/template/product/category.tpl:
./catalog/view/theme/default/template/account/wishlist.tpl:
./catalog/view/javascript/common.js:
./catalog/view/theme/default/template/module/featured.tpl:
./catalog/view/theme/default/template/module/special.tpl:
./catalog/view/theme/default/template/module/bestseller.tpl:
./catalog/view/theme/default/template/module/latest.tpl:
./catalog/view/theme/default/template/product/product.tpl:
./catalog/view/theme/default/template/product/manufacturer_info.tpl:
./catalog/view/theme/default/template/product/special.tpl:
./catalog/view/theme/default/template/product/compare.tpl:
./catalog/view/theme/default/template/product/search.tpl:
./catalog/view/theme/default/template/product/category.tpl:
./catalog/view/theme/default/template/account/wishlist.tpl:
./catalog/view/javascript/common.js:
Hi, an easy case edit function addTocart()//in common.js
find
add
after
and product.tpl
there r 2 file to edit.

find
Code: Select all
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>');
$('.success').fadeIn('slow');
$('#cart_total').html(json['total']);
$('html, body').animate({ scrollTop: 0 }, 'slow');
window.location.href = 'index.php?route=checkout/cart';//i'm put this line and work perfect!!
}
Code: Select all
window.location.href = 'index.php?route=checkout/cart';
Code: Select all
$('html, body').animate({ scrollTop: 0 }, 'slow');
Code: Select all
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>');
$('.success').fadeIn('slow');
$('#cart_total').html(json['total']);
$('html, body').animate({ scrollTop: 0 }, 'slow');
window.location.href = 'index.php?route=checkout/cart';
}



ร้านค้าออนไลน์
OpenCart Thailand Support Forum
How to Upgrade oc1.5 to 2.0.1.1
Upgrading OpenCart From v.1.4 or v.1.5 to V.2.2 Step by step
i found this solution in common.jsoolongtea wrote:I also don't want the ajax effect of "add to cart" because there is only one product we are going to sell.
Does anybody has solution on this?
thanks!
change this
Code: Select all
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>');
$('.success').fadeIn('slow');
$('#cart_total').html(json['total']);
$('html, body').animate({ scrollTop: 0 }, 'slow');
}
Code: Select all
if (json['success']) {
$('#cart_total').html(json['total']);
window.location.href = 'index.php?route=checkout/checkout';
}
And if you want to remove the ajax from "add to wishlist" too it's basically the same thing except the new code would be
Code: Select all
window.location.href = 'index.php?route=account/wishlist';
Hi my problem is slightly different but I think its in the same vain
The item selected only appears in the in the cart when you mouse over the cart items at the top of the page. It also throws out the following error in the error log
PHP Notice: Use of undefined constant php - assumed 'php' in /websites/123reg/LinuxPackage22/la/ca/sa/lacasamia.co.uk/public_html/catalog/view/theme/theme306/template/product/product.tpl on line 450
The site url is
http://www.lacasamia.co.uk
many thanks
The item selected only appears in the in the cart when you mouse over the cart items at the top of the page. It also throws out the following error in the error log
PHP Notice: Use of undefined constant php - assumed 'php' in /websites/123reg/LinuxPackage22/la/ca/sa/lacasamia.co.uk/public_html/catalog/view/theme/theme306/template/product/product.tpl on line 450
The site url is
http://www.lacasamia.co.uk
many thanks
Who is online
Users browsing this forum: No registered users and 32 guests