Liquid, JavaScript, themes, sales channels
Hi
I'm trying to update cart attributes like this
fetch('/cart/update.js', {
method: "POST",
headers: {
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/json;'
},
body: JSON.stringify({
attributes: {
foo: { bar: "123" }
}
})
})
It successfully updates the cart, saves the result as a string (it should be an object, right?)
But... the string is a stringified object of PHP, not Javascript
Does anyone know how to deal with this?
Solved! Go to the solution
This is an accepted solution.
So I found my temporary solution
- stringify the foo object
- send it
- parse back when need to use
But I guess that it shouldn't be the official way!
This is an accepted solution.
So I found my temporary solution
- stringify the foo object
- send it
- parse back when need to use
But I guess that it shouldn't be the official way!
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024