SalesforceCommerceCloud / pwa-kit

React-based JavaScript frontend framework to create a progressive web app (PWA) storefront for Salesforce B2C Commerce.
https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/pwa-kit-overview.html
BSD 3-Clause "New" or "Revised" License
284 stars 134 forks source link

[BUG] Basket default shipping method not being updated on currency change #1463

Open GerFres opened 1 year ago

GerFres commented 1 year ago

Summary

On a multi locale and currency site, shipping method pushed to the basket by default does not update whenever the currency of the basket changes, producing unwanted behaviors on tax calculation on cart.

Let's say we have one site with two locales and currencies:

When we navigate to the storefront a basket will be created with EUR as currency and the default shipping method for the EUR currency will be pushed into the basket.

Then if we switch locales to EN-US, the currency of the basket gets updated to USD but the shipping method pushed to the basket is still the same as before, having now USD as currency but a EUR shipping method. Then if I add a product to the basket the taxTotal will be null.

Steps To Reproduce

  1. Go into a site that has multiple locales and currencies
  2. Check the content of the basket (Currency and shipping method)
  3. Go to a different locale that has a currency different than the default one
  4. Check that the currency of the basket now changed but the shipping method is still the same

Expected result

Shipping method to be adjusted to the default shipping method of the updated currency

Actual result

Shipping method does not updated regardless the value of the currency of the basket. This has impact with the tax calculation on the cart and it will be null. It only gets fixed if the customer selects a shipping method in the checkout but until then the taxTotal is null if a product has been added to the basket.

System Information (as applicable)

Browser: Node version: pwa-kit version: Desktop OS: Mobile Device Info:

Additional information

Screenshot 2023-09-27 at 10 04 23

Screenshot 2023-09-27 at 10 06 57 Screenshot 2023-09-27 at 10 12 00
git2gus[bot] commented 1 year ago

This issue has been linked to a new work item: W-14239814

wjhsf commented 1 year ago

Thanks for reporting this, @GerFres! While investigating this, I also noticed that if a user does not update the shipping method, they can make it all the way to submitting the order, which fails due to taxTotal (and related fields) not being properly set.