elasticpath / epcc-react-pwa-reference-storefront

Elastic Path Commerce Cloud Reference Storefront Progressive Web Application in React
https://epcc-reference.elasticpath.com/
GNU General Public License v3.0
13 stars 9 forks source link

Product page: changing SKU options does not update displayed details #103

Open plundaahl-ep opened 3 years ago

plundaahl-ep commented 3 years ago

Step 1: Are you in the right place?

Step 2: Describe your environment

Step 3: Describe the problem:

This bug occurs on the product page for multi-variant products.

When the user changes the variant configuration for a multi-variant product, none of the page details (aside from the variation options) are updated. This can be most clearly seen when the prices for child products are different to that of the parent. In this case, when the user adds the product to the cart, the line item in the cart will have a different price to that advertised on the product page.

However, this also affects:

Steps to reproduce:

  1. Load a multivariant page where the price for the parent and child products are different
  2. Change one of the SKU options
  3. Click add-to-cart
  4. Open the cart

Observed Results:

Notice that the price for the added item and the price on the product page do not match.

Expected Results:

Assuming there are no coupons or promotions applied, the price of the line-item in the cart should match that of the item on the product page.

Relevant Code:

The relevant code is in product.tsx. Note that the handleVariationChange function, which is passed into VariationsSelector on line 231, is simply updating the product ID (line 108).

For the expected behavior to occur, we would need to load the child product from the API when the user updates the SKU options.

plundaahl-ep commented 3 years ago

Just a quick note: I believe that this is at least partially-related to this issue. As I mentioned in my comment on that issue, I believe the problem is really one of separating out the domain model.

I believe that an accurate domain model for the Product component would include:

When the user changes the SKU configuraiton in the VariationsSelector, I don't think it should just be updating the product ID - I think it should be fetching the entire product.

Thanks!

kaiyuancheng commented 3 years ago

Bug created: https://elasticpath.atlassian.net/browse/MT-6134 However, the price in the cart actually reflects the right one been added.

kaiyuancheng commented 3 years ago

This is fixed now in ticket https://elasticpath.atlassian.net/browse/MT-6134. @yasiloghmani please update when the code merged