adobe / aem-core-cif-components

A set of configurations and components to get you started with AEM Commerce development
Apache License 2.0
103 stars 80 forks source link

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

Open danielkoch opened 2 years ago

danielkoch commented 2 years ago

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.

buuhuu commented 2 years ago

@adobe export issue to Jira project CIF

github-jira-sync-bot commented 2 years ago

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

buuhuu commented 2 years ago

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

danielkoch commented 2 years ago

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.

buuhuu commented 2 years ago

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