On this page
Why this happens
A personalized item and its plain counterpart can share a variant ID while occupying separate lines. A quantity control that targets only the variant can therefore modify the wrong purchase.
Implementation
Render each cart row with its own Liquid item.key in an escaped data attribute. Send the current key as the string id and the desired integer quantity to the locale-aware change endpoint. Serialize mutations and rebuild the cart controls from the returned cart after every successful change.
Example
const response = await fetch(window.Shopify.routes.root + 'cart/change.js', {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({id:currentKey, quantity:2})});
if (!response.ok) throw new Error('Cart update failed');
const cart = await response.json();
On failure, reload cart state before offering another attempt. Do not keep old keys in local storage or retry against a guessed variant.
- Add two copies of one variant with different properties
- change only the second row
- remove the first
- apply a discount and refresh the keys
- repeat under a translated storefront.

