Reorder items in Cart.liquid page. But the quantity in check out page is still using original order.

Jake_Lin
Shopify Partner
7 0 0

I reordered the product items in Cart.liquid by using liquid script. But when I check out the cart, the items' quantities in the check out page are wrong. The quantities are associated to original product order(It is based on the sequence when the user adds the product to the cart). I am assuming this is a Shopify bug. Would you please confirm that? And when can they fix that? If it's not a Shopify bug? What have I done wrong with that?

Replies 9 (9)
Jason
Shopify Expert
10438 169 2081

I am assuming this is a Shopify bug

Not a bug - it's working as intended. You're just choosing to show them in a different order - but that does not change the original data / variables.

 

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.
Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.
★ http://freakdesign.com.au ★
Jake_Lin
Shopify Partner
7 0 0

Yes, I displayed them in my expected order. But is any way I can rearrange the original data / variables. cart.items is a array. How can I change the sequence of the items in this array?

Jason
Shopify Expert
10438 169 2081

I do not think you can (other than removing and re-adding the items in the desired sequence). Ready to be proved wrong here...

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.
Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.
★ http://freakdesign.com.au ★
Gavinator
Shopify Partner
1264 9 104

I ran into this problem before and worked around it by using the Javascript API. Something along these lines:

<script>
    $('#cartitems tr a.remove').click(function() {
      // code here to update quantity of this item using Ajax, then set document location to /cart
    });

    // you need to handle quantity updates as well

    // handle checkout
    $('input[name="checkout"]').click(function() {
      document.location.href = "/checkout";
      return false;
    })
</script>

 

www.bookthatapp.com
Caroline_Schnap
Shopify Staff
5705 1 357

Hello Jake!

If you specify the quantity like so, in cart.liquid, specifying the line item ID, you should be good:

<input type="text" size="4" name="updates[{{ item.id }}]" id="updates_{{ item.id }}" value="{{ item.quantity }}" onfocus="this.select();" class="tc item-quantity" />

 

Caroline_Schnap | 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

Akshay_Mahajan
New Member
3 0 0

Thanks Caroline! This is a neat solution! Can this be added by default to themes? Most of the themes have updates[] as the quantity box name.

Caroline_Schnap
Shopify Staff
5705 1 357

Themes need to keep on using updates[] to support Line Item Properties. It would be a huge trade-off to break that compatibility, just to have the ability to reverse line items.

Caroline_Schnap | 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

tsawicki
New Member
1 0 0

I ran into the same problem - this is probably my solution as well.

Abbab
Tourist
6 1 0

Hello,

I'm having the same issue but adding the name="updates[{{item.id}}]" is not solving the issue. Is there something I'm doing wrong with my input field code ?

 

  <input id="updates_{{ item.key }}" class="cart__qty-input" type="number"
                    value="{{ item.quantity }}" min="0" pattern="[0-9]*"
                    data-quantity-input data-quantity-item="{{ forloop.index }}" name="updates[{{item.id}}]" data-quantity-input-mobile data-role="product-quantity-mobile">

 

Thank you,