Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥 Ajax Cart Quantity Bug #2994

Open
openxthinking opened this issue Sep 15, 2023 · 10 comments
Open

🔥 Ajax Cart Quantity Bug #2994

openxthinking opened this issue Sep 15, 2023 · 10 comments

Comments

@openxthinking
Copy link

openxthinking commented Sep 15, 2023

Describe the current behavior

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

  • Adds the available products to the cart.
  • Fails to update both the "drawer" and the "cart bubble".
  • Subsequently, an error is thrown.

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)

  • Dawn Version 11.0.0
  • Chrome Version 117.0.5938.62
  • Firefox version 117.0.1
  • macOS Version 13.5.2

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.

Screen.Recording.2023-09-15.at.19.11.49.mp4
@EvgeniyMukhamedjanov
Copy link

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
Copy link

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
Copy link

bakura10 commented Jan 9, 2024

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
Copy link
Contributor

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
Copy link

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
Copy link
Contributor

ludoboludo commented Jan 11, 2024

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
Copy link

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

@zainalidst
Copy link

Hi,

I am working on store development and using the dawn theme give me same behaviour.

Cart drawer section not load when /cart/add.js response status is 422. Theme developer not handle this bug and I am very strange that why dawn is not remove this bug in very release.

@ludoboludo
Copy link
Contributor

So the documentation has been updated to reflect that the maximum quantity possible will be added to the cart while erroring. We would now need to tweak our handling of that error to clearly show the user what happened.
Link to the docs

@msev
Copy link

msev commented Oct 14, 2024

Hi @ludoboludo,

It doesn't make sense that an add to cart can be done, but that the API return is an error.
Adding to cart should not happen in this case.

If you think it makes more sense to add to cart, then the API return should be a success and not an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants