Nested cart lines for addons now works šŸ”„

It can show both places but relies on some liquid logic. There’s some examples in the post.

1 Like

Oh I can use this code snipet to display in cart page or cart drawer, right?

I have more concern whether we can remove the nest items only?

Hey again. Is this what you’re looking for?

oh Thanks. The cart clears both parent & nest items, but the children aren’t reflected inside the response

What would be the best approach to set the instructions (can_remove: false) or (can_update_quantity: false) during the add to cart?

Thank you!

1 Like

Fetch request

await fetch(window.Shopify.routes.root + 'cart/add.js', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        items: [
          { id: variant_id, parent_line_key: key, quantity: quantity, instructions: { can_update_quantity: false, can_remove: false } }
        ]
      })
 });

Payload

{
    "id": 44875894096044,
    "parent_line_key": "39372678234284:431608d3917496767dae82679a108e0e",
    "quantity": 3,
    "instructions": {
        "can_update_quantity": false,
        "can_remove": false
    }
}

Response

{
    "id": 44875894096044,
    "properties": {},
    "quantity": 3,
    "variant_id": 44875894096044,
    "key": "44875894096044:6ee20082f3ef3dc41248e430927e01d0",
    "parent_relationship": {
        "parent_key": "39372678234284:431608d3917496767dae82679a108e0e"
    },
    "instructions": {
        "can_remove": true,
        "can_update_quantity": true
    },
    ...
}
1 Like

Hey @app

I’m note sure! I have not tested that.

Honestly I’m unsure if that is a read_only property?

Yes indeed. It looks like the documentation is unfinished.