SalesforceCommerceCloud/pwa-kit

[BUG] Uncaught exception when adding a number of items to cart larger than the available stock

開放

#388 建立於 2022年2月8日

 (1 則留言) (0 個反應) (0 位負責人)JavaScript (234 個分叉)github user discovery
Acknowledgedgood first issue

倉庫指標

星標
 (359 顆星)
PR 合併指標
 (平均合併 2天 11小時) (30 天內合併 38 個 PR)

描述

Summary

The useBasket hook throw an exception when a shopper tries to add more products to their cart than is available in stock.

useBasket.js:51 Uncaught (in promise) Error: [object Object] at useBasket.js:51

This is because we're not handling the API response with the exception type ProductItemNotAvailableException:

{"_v":"21.3","fault":{"arguments":{"productId":"701642842637M","quantity":110.0},"type":"ProductItemNotAvailableException","message":"The product '701642842637M' isn't available for quantity '110'."}}

Steps To Reproduce

  • Navigate to the PDP of any product.
  • Set quantity to 99 and repeatedly click the Add to cart button until the exception is thrown.

Expected result

The user is shown a useful error saying that the item is not available at the requested quantity.

Actual result

A Something went wrong Try again! popup appears. A 400 error appears in the devtools console.

@ W-9231893 @

貢獻者指南