Fetching cart contents on an external domain

Highlighted
New Member
1 0 0

Up until Chrome 80's samesite cookie changes, we were fetching Shopify's cart contents using:

 

$.ajax({
        dataType:'jsonp',
        url: '//<shop>.myshopify.com/cart.json',
        success: function(data){
          var response = $.post(
            '/' + drupalSettings.path.currentLanguage + '/cart',
            data,
            function (response) {
              <snip>
            }
          );
        }
      });

With chome's samesite cookie change, this no longer works as the session is not passed/used. Is there any alternative best practice to load cart contents on an external domain?

0 Likes
Highlighted

Hi, 

 

With chome's samesite cookie change, this no longer works as the session is not passed/used.

What makes you think this is the cause? The AJAX API does not require credentials so cookies being sent should not matter and using JSONP avoids CORS restrictions. Can you provide more info?

ScreenStaring
Software Development & Consulting
0 Likes
Highlighted
Tourist
3 0 0

Hello,

We are also facing similar issue (cannot fetch cart contents via jsonp-requests).
I also assume this is due to the chrome's samesite cookie change (this started working after I disabled the samesite cookie changes in chrome settings).

I guess it happens because the jsonp-request cannot read this cookie (which contains the cart token):
cart_token.png
and because the jsonp-request cannot read this cookie, the request will always return new (empty) cart instead of the customers 'actual' cart.

We also looking for any solution to overcome this issue. Currently, the only feasible one seems to be that we should populate the data to our custom checkout application via POST request (submitting the form in the cart-page) but this won't still solve all the issues (e.g clearing the users cart).

Kind regards,

0 Likes