Problems fetching cart contents and adding to cart using remote sites

Highlighted
New Member
1 0 0

Hi,

I've been running the following with at least two Shopify stores for years. They are remote sites that just use Shopify for the cart and checkout process.

We display the cart item count on the remote site using this:

 

 

STORE_URL = "https://store.myshopify.com/";
$.ajax({
type: 'GET',
url: STORE_URL + 'cart.json',
dataType: 'jsonp',
success: function(data) {

var item_count = data['item_count'];
$('#cartitems').text(item_count);

}
});

 

 

Since early October 2020, it's been returning a valid, but empty cart. Visiting cart.json in a browser tab returns a correctly populated cart.

At the same time, the following Add To Cart form has gone from correctly adding an item to the cart, to starting a new cart with the new item added.

 

 

<form action="https://store.myshopify.com/cart/add" method="post">
<input type="hidden" name="return_to" value="cart">
<input type="hidden" name="id" value="xxxxxxxxxx">
<button class="button primary">Add to cart</button>
</form>

 

 

I thought it might be a Chrome update, but, no, it happens in Edge as well. I suspect Shopify have changed something domain or cookie related. Unfortunately, Shopify support just keep repeating that it's something wrong with my theme. It isn't, it's functionality that has been around for years and has stopped working. But I can't get them to look into it properly.

Has anyone else encountered this yet? I have it occurring in two independent remote sites using different Shopify stores, but only since the beginning of this month.

Also, what's the current best practice method for repeating the same functionality on a remote site?

Cheers.

0 Likes