Skip to content

Instantly share code, notes, and snippets.

@ihorduchenko
Created December 6, 2024 23:32
Show Gist options
  • Save ihorduchenko/cdda21ee1bf98eeb1b5aa46e5908bc5d to your computer and use it in GitHub Desktop.
Save ihorduchenko/cdda21ee1bf98eeb1b5aa46e5908bc5d to your computer and use it in GitHub Desktop.
Update cart line item using 'change' method and line items key
<script>
let productObject = {
id: itemInCart.key, // important to use key of type string
quantity: 1,
properties: {
'PropertyName': getCookie(PropertyName)
}
};
return fetch('{{ routes.cart_change_url }}.js', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(productObject) // no additional braces needed
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment