-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[PWA-413] [Cart Page Edit] Price Does not get updated after changing the color/size. #2483
Conversation
…nts to show current selected price.
|
Performance Test Results The following fails have been reported by WebpageTest. These numbers indicates a possible performance issue with the PR which requires further manual testing to validate. https://pr-2483.pwa-venia.com : LH Performance Expected 0.85 Actual 0.57, LH Best Practices Expected 1 Actual 0.92 |
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.
Looks good to me.
As our core workflows become more complicated in order to handle edges like this, let's keep an eye on it. The more types of products we support, the more strain it's going to put on talons as our only layer of abstraction; we may need to add another layer at some point.
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.
This seems functional but I wasn't sure about the initial state expectations. Lets talk about it.
import { useAppContext } from '../../../../context/app'; | ||
|
||
export const useEditModal = () => { | ||
const [{ drawer }, { closeDrawer }] = useAppContext(); | ||
const isOpen = drawer === 'product.edit'; | ||
|
||
const [variantPrice, setVariantPrice] = useState(); |
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.
This is undefined
initially. What happens if the item in the cart is a configurable item? I know it falls back to price
but could that be wrong? Perhaps we need to do the calculation here.
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.
The first render for this component will have item = undefined
, so it wouldn't be that easy. I could add an effect, but I didn't really see the purpose when ProductDetail
already had the data it needed to render price. Instead of having to handle a bunch of different states for opening, then resetting on close, I passed this responsibility down to ProductForm
.
BTW - you can only edit Configurable product right now (assuming you meant isn't a configurable item)
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.
Ah yes, I mistyped.
What I meant was that when you first click on a product to edit the value for variant was "undefined". It seemed to render correctly regardless, but maybe that was by coincidence?
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.
By design. I'm willing to make this change, but did want to do some validation. If I add a product to my cart that is on sale, but don't checkout until a day later when that product is no longer on sale, do I still get that product at the sale price? I don't know the answer to that, but that would be a reason to use cart price instead of variant price. There might be other use cases as well where cart price is the accurate value, and is what we want to render.
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.
If variant price reflects product specific sales I think it's fine to only use that. Would be odd to reflect cart sales such as BOGO or <$X discounts in an edit view.
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.
If I add a product to my cart that is on sale, but don't checkout until a day later when that product is no longer on sale, do I still get that product at the sale price? I don't know the answer to that, but that would be a reason to use cart price instead of variant price.
We can assume that if a sale price expires before a shopper completes a purchase, the sale price is forfeit. If there are special cases where that's not true, someone would have to handle those cases as exceptions.
edit: Also, in general, we should use null
rather than undefined
as an initial value for useState()
.
@@ -11,16 +11,20 @@ import ProductForm from './productForm'; | |||
|
|||
const EditModal = props => { | |||
const { item, setIsCartUpdating } = props; | |||
const talonProps = useEditModal(); | |||
const { handleClose, isOpen } = talonProps; | |||
const talonProps = useEditModal({ item }); |
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 notice you pass the item here - is that to do the calculation of the variant price on initial render? You aren't using it anymore in the talon though.
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 attempted your suggestion to initialize in the talon at first, but went the simple route. Will remove this prop.
|
||
const classes = mergeClasses(defaultClasses, props.classes); | ||
const rootClass = isOpen ? classes.root_open : classes.root; | ||
|
||
const bodyComponent = item ? ( | ||
<div className={classes.body} key={item.id}> | ||
<ProductDetail item={item} /> | ||
<ProductForm item={item} setIsCartUpdating={setIsCartUpdating} /> | ||
<ProductDetail item={item} variantPrice={variantPrice} /> |
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.
variantPrice
is undefined if you open the edit modal and don't click on anything.
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.
Yes. We render cartItem
price until a new variant is selected.
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.
So if the item in the cart is a variant of the default, cartItem.price
will be the selected variant price not the default price?
Went ahead and QA'ed this, looks good. |
Description
Steps -
Expected - Price should get updated based on selection.
Actual - Price is static, user will get confused after seeing the update on Cart page.
Note - Same issue exists on Mini Cart Edit window as well but will be part of mini cart refactor?
Related Issue
Acceptance
Verification Stakeholders
Specification
Verification Steps
⬆️ Use repro steps in description ⬆️
Screenshots / Screen Captures (if appropriate)
Checklist