cartjs icon indicating copy to clipboard operation
cartjs copied to clipboard

Safari - Issue with adding the first product to cart

Open Legic opened this issue 6 years ago • 4 comments

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?

Legic avatar Feb 04 '19 15:02 Legic

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 avatar Feb 06 '19 09:02 Legic

@Legic is this still an active issue for you?

gavinballard avatar Sep 20 '19 09:09 gavinballard

@Legic is this still an active issue for you?

Yes. I'm still using the ajax native call for this.

Legic avatar Sep 30 '19 06:09 Legic

As of now, this has still not been fixed. Still using the work-around.

Legic avatar Jan 06 '20 23:01 Legic