aem-core-cif-components
aem-core-cif-components copied to clipboard
AddToCard action not throwing an consumable response if product is out-of-stock
Expected Behaviour
If add to cart query is running against an out-of-stock product it should expose the error to the frontend. Otherwise it's impossible to implement a user interface an inform the user.
Actual Behaviour
Request that is trigged by the DOM event aem.cif.add-to-cart throw the following error:

Reproduce Scenario (including but not limited to)
Product must be out-of-stock
Steps to Reproduce
- Click on "Add to cart" on a product that is out-of-stock
- Inspect browser console
- Check cart amount (no changes)
Platform and Version
AEM v6.9 CIF components, v2.4.0 (Magento Cloud)
Sample Code that illustrates the problem
No example needed.
Logs taken while reproducing problem
Browser console see above.
@adobe export issue to Jira project CIF
:white_check_mark: Jira issue CIF-2904 is successfully created for this GitHub issue.
You are right, we have a mechanism for that for the wish list. Doing the same for add to cart would certainly be useful.
https://github.com/adobe/aem-core-cif-components/blob/master/react-components/src/talons/Wishlist/useAddToWishlistEvent.js#L46-L62
Thanks for the hint. Yes, similar solution in the "Add to Cart" event would be helpful. In addition: Also the name of the product itself in here: https://github.com/adobe/aem-core-cif-components/blob/master/ui.apps/src/main/content/jcr_root/apps/core/cif/components/commerce/product/v1/product/clientlib/js/addToCart.js#L117-L120 would help to build a helpful user-interface.
In addition: Also the name of the product itself This will be added with https://github.com/adobe/aem-core-cif-components/pull/949/files#diff-d974f98a4343d70995ce10ca3ad8c97f28a5f99723ee5a63ff3d0f862f4f60af