Hi, I previously had code in place which was working great. Basically, I had a custom index page designed how I wanted and code for the 'Add to Cart' button on this page that linked directly to the OpenCart checkout. This was in OpenCart version 2.x. Since I've upgrade to 3.x, the code no longer works. I'm assuming some tweaks need to be made to make it work in 3.x?
Here was the code I was using in 2.x
-------------------------
Code for Add to Cart button:
<div class="add-single" onclick="cart.add('50', '1');"></div>
-------------------------
Script within Body tags:
<script>
var cart = {
'add': function(product_id, quantity) {
$.ajax({
url: 'https://mydomain.com/index.php?route=checkout/cart/add',
type: 'post',
data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
dataType: 'json',
beforeSend: function() {
// $('#cart > button').button('loading');
},
complete: function() {
//$('#cart > button').button('reset');
},
success: function(json) {
//$('.alert, .text-danger').remove();
if (json['redirect']) {
location = json['redirect'];
exit;
}
}
});
}
}
</script>
-------------------------
Is there some slight tweak to make this work in the new version of open cart 3.x?
Thanks in advance.
Who is online
Users browsing this forum: No registered users and 139 guests