Hi folks,
I'm not entirely sure this is in the right section, so correct me if I'm wrong. I want to know if there is any way to make the site redirect to the shopping cart after an item has been added? So instead of it just appearing in the cart either at the top or in the sidebar, you get to the screen where you're viewing your cart.
Any help would be much appreciated. Thanks!
I'm not entirely sure this is in the right section, so correct me if I'm wrong. I want to know if there is any way to make the site redirect to the shopping cart after an item has been added? So instead of it just appearing in the cart either at the top or in the sidebar, you get to the screen where you're viewing your cart.
Any help would be much appreciated. Thanks!
Try the following:
open: catalog/view/javascript/common.js
find
change to
Works in ALL 1.5.x OC versions
You may need clear your cache
open: catalog/view/javascript/common.js
find
Code: Select all
function addToCart(product_id) {
$.ajax({
url: 'index.php?route=checkout/cart/update',
type: 'post',
data: 'product_id=' + product_id,
dataType: 'json',
success: function(json) {
$('.success, .warning, .attention, .information, .error').remove();
if (json['redirect']) {
location = json['redirect'];
}
if (json['error']) {
if (json['error']['warning']) {
$('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
}
}
if (json['success']) {
$('#notification').html('<div class="attention" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
$('.attention').fadeIn('slow');
$('#cart_total').html(json['total']);
$('html, body').animate({ scrollTop: 0 }, 'slow');
}
}
});
}
Code: Select all
function addToCart(product_id) {
$.ajax({
url: 'index.php?route=checkout/cart/update',
type: 'post',
data: 'product_id=' + product_id,
dataType: 'json',
success: function(json) {
$('.success, .warning, .attention, .information, .error').remove();
if (json['redirect']) {
location = json['redirect'];
}
if (json['error']) {
if (json['error']['warning']) {
$('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
}
}
if (json['success']) {
location = 'index.php?route=checkout/cart';
}
}
});
}
You may need clear your cache
You may also need to look at the foot of the product.tpl file in catalog/view/theme/default/temlate/product/ folder
The product page uses it's own addtocart function similar to the one posted above
The product page uses it's own addtocart function similar to the one posted above
Thanks for the help, solved this with a vQmod, only need the shopping cart add to cart button to direct straight to the shopping cart area as all my products will have options (dates of courses) so customers need to navigate to the product page in any case and I'll be removing the add to cart button in the categories area.
Here is the vQmod;
<modification>
<id>Product Add to cart direct to shopping cart</id>
<version>1.5.1.x_1</version>
<vqmver>1.0.1</vqmver>
<author>Stuart Lade</author>
<file name="/catalog/view/theme/default/template/product/product.tpl">
<operation error="skip">
<search position="replace" offset="7"><![CDATA[
$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img
src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
]]></search>
<add trim="true"><![CDATA[
location = 'index.php?route=checkout/cart';
}
]]></add>
</operation>
</file>
</modification>
Here is the vQmod;
<modification>
<id>Product Add to cart direct to shopping cart</id>
<version>1.5.1.x_1</version>
<vqmver>1.0.1</vqmver>
<author>Stuart Lade</author>
<file name="/catalog/view/theme/default/template/product/product.tpl">
<operation error="skip">
<search position="replace" offset="7"><![CDATA[
$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img
src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
]]></search>
<add trim="true"><![CDATA[
location = 'index.php?route=checkout/cart';
}
]]></add>
</operation>
</file>
</modification>
I'm using the Shoppica theme that doesn't seem to use common.js. Shoppica has a shoppica.js file with the following function:
Can someone help me amend this so when a user clicks Add to cart > they go straight to cart?
Thanks.
Code: Select all
function addToCart(product_id) {
$.ajax({
url: 'index.php?route=module/shoppica/cartCallback',
type: 'post',
data: 'product_id=' + product_id,
dataType: 'json',
success: function(json) {
if (json['redirect']) {
location = json['redirect'];
}
if (json['error']) {
if (json['error']['warning']) {
addProductNotice(json['title'], json['thumb'], json['error']['warning'], 'failure');
}
}
if (json['success']) {
addProductNotice(json['title'], json['thumb'], json['success'], 'success');
$('#cart_menu span.s_grand_total').html(json['total_sum']);
$('#cart_menu div.s_cart_holder').html(json['output']);
}
}
});
}
Thanks.
Who is online
Users browsing this forum: Google [Bot] and 20 guests