aem-core-cif-components icon indicating copy to clipboard operation
aem-core-cif-components copied to clipboard

AddToCard action not throwing an consumable response if product is out-of-stock

Open danielkoch opened this issue 3 years ago • 5 comments

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: AddToCartNoStock

Reproduce Scenario (including but not limited to)

Product must be out-of-stock

Steps to Reproduce

  1. Click on "Add to cart" on a product that is out-of-stock
  2. Inspect browser console
  3. 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.

danielkoch avatar Jun 02 '22 13:06 danielkoch

@adobe export issue to Jira project CIF

buuhuu avatar Jun 02 '22 13:06 buuhuu

:white_check_mark: Jira issue CIF-2904 is successfully created for this GitHub issue.

github-jira-sync-bot avatar Jun 02 '22 13:06 github-jira-sync-bot

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

buuhuu avatar Jun 02 '22 13:06 buuhuu

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.

danielkoch avatar Jun 02 '22 14:06 danielkoch

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

buuhuu avatar Sep 08 '22 11:09 buuhuu