Adding to cart to redirection

ThemeBurn SupportForumsOpenCart ThemesShoppica OpenCart ThemeAdding to cart to redirection

This topic has been marked as not resolved.

Hi there.

I am trying to redirectl directly to the checkout page as I did in shoppica 1. But it is not working with the code you provided in the posts above. This is what I have in common.js :

function addToCart(product_id) {
$.ajax({
url: ‘index.php?route=checkout/checkout’,
type: ‘post’,
data: ‘product_id=’ + product_id,
dataType: ‘json’,
success: function(json) {

if (json['redirect']) {
location = json['redirect'];
} else {
if (json['error'] && json['error']['warning']) {
productNotice(json['title'], json['thumb'], json['error']['warning'], ‘failure’);
}

if (json['success']) {
productNotice(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['html']);

window.location=’index.php?route=checkout/checkout’;
}
}
}
});
}

Do I do something wrong?

October 29, 2012 at 6:29 pm #14778
You will need to register in order to post topics and read replies in the ThemeBurn.com support forums!
November 1, 2012 at 10:03 am #14852

Hi,

I still don’t understand what is wrong in my code. What should I change/replace/delete?

This is what I have in common.js

function addToCart(product_id) {
$.ajax({
url: ‘index.php?route=tb/cartCallback’,
type: ‘post’,
data: ‘product_id=’ + product_id,
dataType: ‘json’,
success: function(json) {

if (json['redirect']) {
location = json['redirect'];
} else {
if (json['error'] && json['error']['warning']) {
productNotice(json['title'], json['thumb'], json['error']['warning'], ‘failure’);
}

if (json['success']) {
productNotice(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['html']);

window.location=’index.php?route=checkout/checkout’;
}
}
}
});
}

November 6, 2012 at 7:13 pm #14991

Hi,

The code you have pasted looks fine. The problem most likely comes from invalid characters.

Try restoring the original catalog/view/theme/shoppica2/javascript/common.js.php and follow the modification instructions at the top of the topic second page.

Best,
ThemeBurn team

November 13, 2012 at 5:35 pm #15159

Hi Themeburn Team,

I tried to do that as well. I restored common.js and followed the instructions. It still doesnt work. This is my code once again. Could you help me, this is very important for me.

function addToCart(product_id) {
$.ajax({
url: ‘index.php?route=checkout/checkout’,
type: ‘post’,
data: ‘product_id=’ + product_id,
dataType: ‘json’,
success: function(json) {

if (json['redirect']) {
location = json['redirect'];
} else {
if (json['error'] && json['error']['warning']) {
productNotice(json['title'], json['thumb'], json['error']['warning'], ‘failure’);
}

if (json['success']) {
productNotice(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['html']);

window.location=’index.php?route=checkout/checkout’;
}
}
}
});
}

function removeCart(key) {

November 13, 2012 at 7:03 pm #15171

Hi,

We will need the website url, admin and ftp access, so we can check.

You can use hidepost to share private information with the support staff.

Best,
ThemeBurn team

November 16, 2012 at 12:32 pm #15251
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.