POST /cart/change.js using line_item.key instead of only variant_id

New Member
2 0 0

I'm trying to POST /cart/change.js updating my line item's quantity using line item's key instead of just the variant ID as shown here:


Reason because I have multiple customized item (same variant ID) with different properties in the cart and If i use only variant ID, it will change all with similar variant ID.


I could update the quantity if i use just the variantID, but it does not work if i use line_item.key instead. where did I went wrong? 

I've assigned gcidcode = line_item.key

I tested {{ gcidcode }} and it display properly on the webpage Eg: 794864053:70ff98a797ed385f6ef25e6e974708ca

Shopify.Cart.GiftWrap.change = function() {
    type: 'POST',
    url: '/cart/change.js', 
    data: { quantity: 1, id: {{ gcidcode }} }, 
    dataType: 'json',
    success: function() { location.href = '/cart'; }

If I assign gcidcode = line_item.variant_id, with the above jQuery, it will update the quantity properly, but it doesn't seems to work with line_item.key.

Shopify Staff
Shopify Staff
436 18 57

Hi, @briantan26 


Elle here from Shopify.


I've moved your post from the Technical Q&A board to our API board as it should receive a better response here.



Elle | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Shopify Staff
Shopify Staff
618 45 84

Hi @briantan26,


What's the error you are seeing? I was able to update quantity using the /cart/change.js endpoint with the following call.'/cart/change.js', { quantity: 5, id: '419432426:1c668117300fdaca18c1a4ad36aeb041' });

Can you give that a try and let me know if you still encounter issues?