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

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?

0 Likes
Shopify Expert
9807 92 1560

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.

 

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
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?

0 Likes
Shopify Expert
9807 92 1560

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

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Shopify Partner
1184 1 64

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 ♥ www.searchifyapp.com ♥ www.productsassistant.com
0 Likes
Shopify Staff
Shopify Staff
5704 0 287

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 from http://11heavens.com ∴ mllegeorgesand AT gmail DOT com
1 Like
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.

0 Likes
Shopify Staff
Shopify Staff
5704 0 287

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 from http://11heavens.com ∴ mllegeorgesand AT gmail DOT com
0 Likes
New Member
1 0 0

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

0 Likes