@W-21294742: No error toast for non-applicable shipping method#3673
Conversation
Signed-off-by: d.phan <d.phan@salesforce.com>
Signed-off-by: d.phan <d.phan@salesforce.com>
| onSuccess: (data) => { | ||
| const noMethods = | ||
| !data?.applicableShippingMethods || data.applicableShippingMethods.length === 0 | ||
| const deliveryOnly = getDeliveryShippingMethods(data?.applicableShippingMethods) |
There was a problem hiding this comment.
We only display shipping methods for delivery/shipping orders.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Signed-off-by: d.phan <d.phan@salesforce.com>
Signed-off-by: d.phan <d.phan@salesforce.com>
| return | ||
| } | ||
|
|
||
| // Don't assign methods until at least one delivery shipment has an address |
There was a problem hiding this comment.
The change to Cart page I mentioned @patricksullivansf
Signed-off-by: d.phan <d.phan@salesforce.com>
patricksullivansf
left a comment
There was a problem hiding this comment.
Looks great to me. I had some complexity concerns for you to consider. no blockers.
| const hasMultipleDeliveryShipments = deliveryShipments.length > 1 | ||
| const [isMultiShipping, setIsMultiShipping] = useState(hasMultipleDeliveryShipments) | ||
| const [openedByUser, setOpenedByUser] = useState(false) |
| } | ||
|
|
||
| const ShipmentMethods = ({shipment, index, currency}) => { | ||
| const ShipmentMethods = ({shipment, index, currency, onShipmentMethodsResolved}) => { |
There was a problem hiding this comment.
nit: onShipmentMethodsResolved seems unnecessarily complicated.
Also, is this a breaking change to the component contract?
There was a problem hiding this comment.
Hmm this is exclusive to one-click checkout, and it's not a breaking change..
As for the onShipmentMethodsResolved : The parent needs to know, per delivery shipment, whether that shipment has no applicable delivery methods (from the API). It uses that to:
- Hide the Continue button when any shipment has no methods
- Show the error toast once when that happens
- Show “No shipping method selected” in MultiShipmentSummary for the right shipments
Removing the callback without changing behavior would mean a more complex setup (e.g. context or parent-owned fetches)
^ Got this from Cursor explanation
…g-method-fix Signed-off-by: Danny Phan <125327707+dannyphan2000@users.noreply.github.com>
Signed-off-by: d.phan <d.phan@salesforce.com>
Signed-off-by: d.phan <d.phan@salesforce.com>
Signed-off-by: d.phan <d.phan@salesforce.com>
…21294742.error-no-shipping-method-fix Signed-off-by: d.phan <d.phan@salesforce.com>
| if (wasMulti && !hasMultipleDeliveryShipments) { | ||
| return | ||
| } | ||
| if (step === STEPS.SHIPPING_OPTIONS) return |
There was a problem hiding this comment.
This useEffect has deliveryAddressStateKey as a dependency.
If the user edits their address while already on SHIPPING_OPTIONS (which seems to be the scenario this PR targets), the effect fires and immediately returns. noMethodsToastShown stays true, so the second useEffect that actually shows the toast short-circuits via if (!singleShipmentNoMethods || noMethodsToastShown) return. The toast will only ever fire once per component mount.
Is that expected ?
There was a problem hiding this comment.
@shethj From my local testing, the path you mentioned is still working fine (error toast fired again after changing delivery address to another invalid state).
AFAIK: it's because the user is sent back to SHIPPING_ADDRESS stage to edit, then when they leave SHIPPING_OPTIONS, the other branch of the effect runs and resets noMethodsToastShown. When they come back to SHIPPING_OPTIONS with the new address, the toast can show again. So in this flow you’d never see the bug...
Signed-off-by: d.phan <d.phan@salesforce.com>
Signed-off-by: d.phan <d.phan@salesforce.com>
Signed-off-by: d.phan <d.phan@salesforce.com>
* @W-21294742: No error toast for non-applicable shipping method Signed-off-by: d.phan <d.phan@salesforce.com> * add changelog Signed-off-by: d.phan <d.phan@salesforce.com> * fix for multi-shipment Signed-off-by: d.phan <d.phan@salesforce.com> * fix edge cases Signed-off-by: d.phan <d.phan@salesforce.com> * minor comment remove Signed-off-by: d.phan <d.phan@salesforce.com> * fixes Signed-off-by: d.phan <d.phan@salesforce.com> * fix duplicate error toast Signed-off-by: d.phan <d.phan@salesforce.com> * fix for false positives error toast Signed-off-by: d.phan <d.phan@salesforce.com> * reuse util func Signed-off-by: d.phan <d.phan@salesforce.com> * lint fix test Signed-off-by: d.phan <d.phan@salesforce.com> * fix a11y cart issue Signed-off-by: d.phan <d.phan@salesforce.com> * skip test temporarily Signed-off-by: d.phan <d.phan@salesforce.com> --------- Signed-off-by: d.phan <d.phan@salesforce.com> Signed-off-by: Danny Phan <125327707+dannyphan2000@users.noreply.github.com>
Fix no error toast for non-applicable shipping method.
Description
Currently in V3, this is what’s being done if there’s no applicable shipping method:
User is told via toast to enter a different address.
Form state is cleared and no method can be selected or submitted.
Progression is blocked until they change the address (e.g. by going back to the Shipping Address step in the checkout flow). There is no in-place "change address" link in this component; navigation back is via the checkout stepper/context (e.g. goToStep).
In Shipping Address, fill out the information and select a state (like
HI- Hawaii) that there is no shipping method (other than the Store Pickup one that should be filtered out in the list of applicable shipping methods).Expected: the behavior above
Actual: an empty Shipping Methods component is shown. No error toast or going back is being done.
Added fix for multi-shipment as well:
Caveats:
Both of these are happening in https://pwa-kit.mobify-storefront.com/ (traditional checkout) as well.
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