Safari 11 issue with the AJAX cart API

New Member
3 0 0

Hi,

I'm having trouble with Safari 11 seemingly not storing cart cookie variables upon a fetch request to the following endpoints:

GET /cart.js

POST /cart/add.js

Running the below function in chrome gives me the full set of cookies required for the cart to work:

addToCart(32498730762285,1)

Chrome CookiesChrome Cookies

However in safari (only version 11) I get nothing:

Screen Shot 2020-07-14 at 8.20.20 AM.png

 

This results in shopify getting a different cart any time a user tries to 'add to cart', meaning that the user can't effectively add anything to cart.

 

My fetch requests look like this:

 

async function getCart(){
      const req = await fetch('/cart.js')
      const res = req.json()
      return res
}

async function addToCart(id,quantity){
     const req = await fetch('/cart/add.js',{ 
      method: 'POST', 
      headers: {'Content-Type': 'application/json'}, 
      body: JSON.stringify({ items: [{ quantity:quantity,id:id }] }) 
     })

     const res = req.json()
     return res
}

 

 

0 Likes