We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Updating line item property from cart page with AJAX API not working

Updating line item property from cart page with AJAX API not working

generalmet
Visitor
2 0 0

Hi, when I try to update line item property in the cart with `cart/change.js`, the endpoint returns 200 but the properties are not updated, seemingly ignored.

This is what I post:

POST /cart/change.js

 

{
  "line": 1,
  "quantity":2,
  "properties": { "gift_wrap": true }
}​

 

 

And the server returns:

 

{"token":"c1-319404902e789b7e37279d056e1023a6","note":"432432fsdf","attributes":{"delivery_date":"2023-11-16"},"original_total_price":3600,"total_price":3600,"total_discount":0,"total_weight":0.0,"item_count":6,"items":[{"id":44354104656127,"properties":{},"quantity":2 ...}

 

 

 

Which is funny as the quantity updated, but the item property field is completely ignored... Does anyone have any idea?

 

Edit: I realize it could be the Shopify Bundles app that prevent me from updating the property. Does anyone have a solution?

 

Replies 2 (2)

PaulNewton
Shopify Partner
8031 687 1647

Drive by take:

"properties": { "gift_wrap": true }

should be an actual string value

"properties": { "gift_wrap""true" }

 

If your using fetch JSON.stringify(data) the data in the fetch body

fetch(window.Shopify.routes.root + 'cart/change.js', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
  "line": 1,
  "quantity":2,
  "properties": { "gift_wrap": "true" }
  })
})
.then(response => {
  return response.json();
})
.catch((error) => {
  console.error('Error:', error);
})

 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


generalmet
Visitor
2 0 0

Hi,

Same result unfortunately:

{
  "line": 1,
  "quantity":2,
  "properties": { "gift_wrap": "true" }
}

 

Result:

{"token":"c1-319404902e789b7e37279d056e1023a6","note":"432432fsdf","attributes":{"delivery_date":"2023-11-16"},"original_total_price":7200,"total_price":7200,"total_discount":0,"total_weight":0.0,"item_count":12,"items":[{"id":44354104656127,"properties":{},"quantity":2,...}