cartjs
cartjs copied to clipboard
Safari - Issue with adding the first product to cart
This only happens on Safari (Version 12.0.2) on the first product you add to cart, if you click add to cart, the cart object it gives you through the event 'cart.requestComplete', is empty. Refreshing the page will show your item in the cart. Any way to fix this? My code relies on the cart object giving the right info.
My code:
var cartCount = {{ cart.item_count }};
$(document).on('cart.requestComplete', function(event, cart) {
console.log('Cart count before adding anything is: ' + cartCount);
console.log('Cart count of the Cart is: ' + cart.item_count);
console.log('This is the cart object:');
console.log(cart);
console.log('This is the event object:');
console.log(event);
});
Could anyone please help me?
Right. I need this fixed asap, so in the case of the safari bug happening, I'm just getting the data like this:
$.ajax({
type: 'get',
url: '/cart.js',
dataType: 'json',
success: function(data){
cart = data;
}
});
@Legic is this still an active issue for you?
@Legic is this still an active issue for you?
Yes. I'm still using the ajax native call for this.
As of now, this has still not been fixed. Still using the work-around.