A space to discuss online store customization, theme development, and Liquid templating.
I'm working on a Shopify store where I need to allow users to customize each cart item separately, even if they have added the same product multiple times with different quantities. For example, a customer can add a product to the cart with a quantity of 2 but would like to personalize each item (e.g., sending cakes to different people by adding From - For products might be same and in bulk quantity).
I have split the quantity in the cart visually using Liquid like this:
{%- for i in (1..item.quantity) -%} <!-- Displaying each item separately --> {%- endfor -%}
However, when I try to update the properties for a specific "split" item (via the line property in the Shopify cart API), it updates all the items in that line instead of just one.
Here’s a snippet of how I'm trying to update the line item in the cart:
const item_variant_id = this.querySelector('input[name="item_variant_id"]'); const item_variant_key = this.querySelector('input[name="item_variant_key"]'); const line_item_index = this.querySelector('input[name="line_item_index"]'); const body = JSON.stringify({ line: line_item_index.value, // 1-based index of the line item in the cart quantity: 2, // just for testing properties: { "FROM": nombreField.value, "FOR": celularField.value } });