Shopify / dawn

Shopify's first source available reference theme, with Online Store 2.0 features and performance built-in.
Other
2.48k stars 3.32k forks source link

🔥 Ajax Cart Quantity Bug #2994

Open openxthinking opened 1 year ago

openxthinking commented 1 year ago

Describe the current behavior

When attempting to add a quantity of products larger than what's available, the theme:

If I then try to reduce the product quantity, the theme throws another error that the specified number of products is already in the cart. However, the "drawer" and "cart bubble" only reflect the correct quantity after a page refresh.

Describe the expected behavior

When sending an Ajax request that results in an error, the theme should not add any products to the cart. Additionally, the "drawer" and "cart bubble" should always reflect the correct quantity of products in the cart without requiring a page refresh.

Version information (Dawn, browsers and operating systems)

Possible solution

The issue seems to originate from the cart API. A potential solution would be to ensure that no products are added to the cart in such scenarios and that the UI elements ("drawer" and "cart bubble") are updated appropriately.

Additional context/screenshots

I've observed this behavior not only in the Dawn theme but also in other themes on the Shopify theme store, pointing towards a more generalized issue with cart API.

https://github.com/Shopify/dawn/assets/70332672/f70a9880-d84d-431d-b08a-477e735563b5

EvgeniyMukhamedjanov commented 1 year ago

I can replicate as well! Left a question in the community. https://community.shopify.com/c/technical-q-a/cart-api-add-js-wrong-behavior/td-p/2227468

EvgeniyMukhamedjanov commented 1 year ago

The same thing is happening with the "change.js" endpoint! If you set the new quantity to be higher than in stock, it will return an error but it will actually add all available quantity to the cart!

bakura10 commented 8 months ago

We are impacted by this as well. The documentation confirms that the expected behavior should not add any product.

Actually, I realized that the behavior is even inconsistent across stores. We have tested some stores where it behaves as instructed in the doc (no product are added in case of error), while some add all the available quantity.

@ludoboludo is it possible to escalate this issue?

ludoboludo commented 8 months ago

Thanks for the flag. Ill track down where the progress on this is 👍 And/or at least make sure there is awareness of the fact that it's still an issue that is impacting negatively merchants and their customers.

EvgeniyMukhamedjanov commented 8 months ago

Hi @ludoboludo Is there any other repo or issue tracker where we can post API related issues? We've found another critical issue in the Shopify Cart API and I'm not where how to reach out Shopify devs. The /cart/update.js returns a wrong item_count value for shopify bundle products. Just described it in linkedin with a screenshot: https://www.linkedin.com/posts/evgeniy-mukhamedjanov_shopify-activity-7150400262665404416-qtsU

ludoboludo commented 8 months ago

There isn't at the moment 🤔 I've relayed the information to the team in question. I'm not sure what's on their current plate and where that will sit in terms of priority though. Anything cart related is pretty sensitive though.

NeevusPeevus commented 2 days ago

Hello! I've encountered this problem while working with a third-party theme, and I've also replicated it using the Dawn theme from the store. Given that this store offers very affordable items, it's not uncommon for customers to enter a quantity that exceeds the available stock, so this has become a significant pain point for the merchant.

Int: https://app.shopify.com/services/internal/shops/74639049002 ZD: https://shopify.zendesk.com/agent/tickets/50730481