-
Notifications
You must be signed in to change notification settings - Fork 212
Merge standard products feature into develop @W-18912410 #2697
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
Changes from all commits
43aee28
cdc9151
23a8b38
447807f
93eae95
b70b3a3
4f5b333
a971777
19ca020
e82bd99
f1a23ea
140bcd3
24fd839
f3a4445
68a6fb8
d281148
70593af
e850378
4b2940e
4c317c4
4e4b412
965fe8b
8a25816
26bb0e6
83988fe
058a7c0
782cfb9
9210d0e
1a2f75a
06703ad
7d1aa03
4386fdb
c474063
ba29cb0
0bc9de4
22bbb48
b5e7dc8
75da2b7
581313c
adcc08b
1e2afd4
95819a0
6896d4f
f3ced62
2a73e91
1e4f31b
6b94099
4ed540f
d81d171
2046cfe
f0f10d6
f241f49
f545efe
fef01e8
b322006
891af1f
dd72f4f
a637f3b
e9f5769
f73f650
eea4a61
6d4b28b
608b3eb
3cfff41
dcd48c0
0b46f33
9d90f80
63bcfb1
fd18a0b
73768d3
8639953
9b2fae0
0bcda60
ca387c8
55ee64a
4bac244
0a45ee8
5707bb5
c915f7c
29d3f06
9f93d7f
353b0ee
6c9a253
7622258
e9b8c14
2ed7ed8
fd8b3bd
260d46f
8ae2dcb
c591eaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,13 @@ | |
| - Password Reset and Passwordless Integration Test [#2669](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2669) | ||
| - Update latest translations for all languages [#2616](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2616) | ||
| - Added support for Buy Online Pick up In Store (BOPIS) [#2646](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2646) | ||
| - Support standard product on PDP [#2518](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2518) | ||
| - Removed the "Edit" button from product cards of Standard Products [#2581](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2581) | ||
| - Support standard product as a child item in bundles [#2574](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2574) | ||
| - Verify einstein activity with standard product [#2650](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2650) | ||
| - Support standard product as a child item in sets [#2636](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2636) | ||
| - Load active data scripts on demand only [#2623](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2623) | ||
| - Refactor Add to Cart in PDP [#2664](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2664) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR did not make it in to develop, so this needs to be pulled |
||
| - Provide base image for convenient perf optimizations [#2642](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2642) | ||
| - Support saving billing phone number on user registration from order confirmation [#2653](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2653) | ||
| - Support saving default shipping address on user registration from order confirmation [#2706](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2706) | ||
|
|
@@ -452,4 +458,4 @@ The versions published below were not published on npm, and the versioning match | |
|
|
||
| ### v1.0.0 (Sep 08, 2021) | ||
|
|
||
| - PWA Kit General Availability and open source. 🎉 | ||
| - PWA Kit General Availability and open source. 🎉 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,8 +125,21 @@ const ProductView = forwardRef( | |
| setChildProductOrderability, | ||
| isBasketLoading = false, | ||
| onVariantSelected = () => {}, | ||
| validateOrderability = (variant, quantity, stockLevel) => | ||
| !isProductLoading && variant?.orderable && quantity > 0 && quantity <= stockLevel, | ||
| validateOrderability = (variant, product, quantity, stockLevel) => { | ||
| if (isProductLoading) return false | ||
|
|
||
| // If product has variations, a variant must be selected | ||
| if (product?.variationAttributes?.length > 0 && !variant) { | ||
| return false | ||
| } | ||
kzheng-sfdc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Check if product (either variant or standard) is orderable and if quantity is valid | ||
| return ( | ||
| (variant?.orderable || product?.inventory?.orderable) && | ||
| quantity > 0 && | ||
| quantity <= stockLevel | ||
| ) | ||
| }, | ||
| showImageGallery = true, | ||
| setSelectedBundleQuantity = () => {}, | ||
| selectedBundleParentQuantity = 1, | ||
|
|
@@ -169,8 +182,8 @@ const ProductView = forwardRef( | |
| return getPriceData(product, {quantity}) | ||
| }, [product, quantity]) | ||
| const canAddToWishlist = !isProductLoading | ||
| const isProductASet = product?.type.set | ||
| const isProductABundle = product?.type.bundle | ||
| const isProductASet = product?.type?.set | ||
| const isProductABundle = product?.type?.bundle | ||
kzheng-sfdc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const errorContainerRef = useRef(null) | ||
| const [pickupEnabled, setPickupEnabled] = useState(false) | ||
| const storeName = selectedStore?.name | ||
|
|
@@ -223,7 +236,7 @@ const ProductView = forwardRef( | |
| const validateAndShowError = (opts = {}) => { | ||
| const {scrollErrorIntoView = true} = opts | ||
| // Validate that all attributes are selected before proceeding. | ||
| const hasValidSelection = validateOrderability(variant, quantity, stockLevel) | ||
| const hasValidSelection = validateOrderability(variant, product, quantity, stockLevel) | ||
| const showError = !isProductASet && !isProductABundle && !hasValidSelection | ||
| const scrollToError = showError && scrollErrorIntoView | ||
|
|
||
|
|
@@ -292,7 +305,7 @@ const ProductView = forwardRef( | |
| return | ||
| } | ||
| try { | ||
| const itemsAdded = await addToCart(variant, quantity) | ||
| const itemsAdded = await addToCart([{product, variant, quantity}]) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hi, @sf-emmyzhang we just removed this change in #2729. Is there a benefit to adding it back?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Product is part of standard product changes and is needed for standard products to work
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm... before BOPIS or standard-product the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the code to account for both features (commit)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: for the record I still don't think this change is needed nor advisable. We're changing the data contract between |
||
| // Open modal only when `addToCart` returns some data | ||
| // It's possible that the item has been added to cart, but we don't want to open the modal. | ||
| // See wishlist_primary_action for example. | ||
|
|
@@ -390,7 +403,7 @@ const ProductView = forwardRef( | |
| if ( | ||
| !isProductASet && | ||
| !isProductABundle && | ||
| validateOrderability(variant, quantity, stockLevel) | ||
| validateOrderability(variant, product, quantity, stockLevel) | ||
| ) { | ||
| toggleShowOptionsMessage(false) | ||
| } | ||
|
|
@@ -402,6 +415,12 @@ const ProductView = forwardRef( | |
| } | ||
| }, [variant?.productId, quantity]) | ||
|
|
||
| useEffect(() => { | ||
| if ((isProductPartOfBundle || isProductPartOfSet) && product && product.type?.item) { | ||
| onVariantSelected(product, null, childOfBundleQuantity || quantity) | ||
| } | ||
| }, [product, childOfBundleQuantity, quantity, isProductPartOfBundle, isProductPartOfSet]) | ||
kzheng-sfdc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| useEffect(() => { | ||
| if (isProductPartOfBundle || isProductPartOfSet) { | ||
| const key = product.itemId ?? product.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.
Small knit, but maybe just put the last PR (this one) in the changelog, i dont think we ended up adding all the statements for the other features.