Skip to content
This repository has been archived by the owner on Aug 30, 2018. It is now read-only.

Cart and Change.js - Ajax cart treats inventory different to normal cart #579

Open
jonathan-bird opened this issue Sep 20, 2016 · 0 comments

Comments

@jonathan-bird
Copy link

jonathan-bird commented Sep 20, 2016

Issue

There's a discrepancy we found that the AJAX Cart doesn't update the quantity of an item if it doesn't have anymore quantity to add (which makes sense, although it should show error that no more available which it doesn't) - we are also using .split in Shopify script.

Through normal cart, I can increase quantity of this item to 10 with no worries and click "update cart" and still shows 10. Only when I go to checkout does it actually show an error which is a poor UX for the customer.

The discrepancy between the two types of carts meant that we didn't know we didn't have enough inventory to cover it because the ajax cart kept removing the items that we added in the liquid cart.

Replicate

1 - Through Shopify script, split an item after 1 and add 3 to cart (through liquid cart, non ajax cart), see that it splits correctly.

Split example:

if original_line_item.quantity >= 1
   new_line_item = original_line_item.split(take: 1)
   new_line_item.change_line_price(Money.new(cents: 500), message: "Third hat for 5 dollars")
  cart.line_items << new_line_item
end

2 - Open ajax cart, see 2 different items,
3 - Click update quantity of either items. Notice that the item gets removed from the cart.

@jonathan-bird jonathan-bird changed the title Cart and Change.js bug - Ajax cart doesn't update quantity after Shopify script uses .split, and removes item if already split through normal cart Cart and Change.js - Ajax cart treats inventory different to normal cart Sep 20, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant