-
Notifications
You must be signed in to change notification settings - Fork 126
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
W 15586246/removed out of stock product from cart #1881
W 15586246/removed out of stock product from cart #1881
Conversation
…product-from-cart' into W-15586246/removed-out-of-stock-product-from-cart
handleUnavailableProducts = noop | ||
}) => { | ||
const unavailableProductIdsRef = useRef(null) | ||
const ids = productIds.length ? productIds : productItems.map((i) => i.productId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this is the main change from the previous PR (#1865)
So now we can either set productIds (the previous API) or productItems (the new API). I think this makes sense to prioritize the current behavior so existing projects will opt in to transition to the new API rather than having the new API forced on them.
I've verified that I am prompted to remove the item from my basket once I make the item unavailable in BM. |
if ( | ||
!isWishlist && | ||
(!inventory?.orderable || | ||
(inventory?.orderable && productItem?.quantity > inventory.stockLevel)) | ||
) { | ||
unOrderableIds.push(id) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the logic here still assumes that productItems
prop is passed in. Can we tweak the logic like this?
- If
productIds
props is passed in, logic will check forresProductIds
only. - If
productItems
is passed in, the logic will check for bothresProductIds
andunOrderableIds
.
...es/template-retail-react-app/app/components/unavailable-product-confirmation-modal/index.jsx
Outdated
Show resolved
Hide resolved
...emplate-retail-react-app/app/components/unavailable-product-confirmation-modal/index.test.js
Show resolved
Hide resolved
…product-from-cart' into W-15586246/removed-out-of-stock-product-from-cart
(inventory?.orderable && productItem?.quantity > inventory.stockLevel)) | ||
) { | ||
unOrderableIds.push(id) | ||
if (productItems.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edge case: if both productIds and productItems are passed in, we prioritize using productIds as it is the older behavior that will not break existing implementaions.
But here the condition is to run the extra logic if productItems have been sent in. Should this also have a condition where we don't run this block if productIds have length?
So rather than if (productItems.length)
we use if (productItems.length && !productIds.length)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I think here we should have a warning to not allow two props being passed at the same time. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, if they pass in both productIds and productItem, they will have extra behavior where low stock /out of stock products in basket being removed depends on the productIds that they pass in. I think it should be fine. 🤔
Description
Some products can be out of stock during shopping journey. We want to make sure out of stock will also removed before allowing shoppers to navigate from Cart to checkout page. At the moment, we have the unavailableModal which will promot shoppers to remove unavailable products, we should include out of stock products
Related issue: #1759
This PR attempted to make #1865 a non-breaking change for UnavailableProductModals
Types of Changes
Changes
How to Test-Drive This PR
Checklists
General
Accessibility Compliance
You must check off all items in one of the follow two lists:
or...
Localization