Skip to content

@W-21294742: No error toast for non-applicable shipping method#3673

Merged
dannyphan2000 merged 16 commits intodevelopfrom
dannyphan2000.W-21294742.error-no-shipping-method-fix
Mar 2, 2026
Merged

@W-21294742: No error toast for non-applicable shipping method#3673
dannyphan2000 merged 16 commits intodevelopfrom
dannyphan2000.W-21294742.error-no-shipping-method-fix

Conversation

@dannyphan2000
Copy link
Contributor

@dannyphan2000 dannyphan2000 commented Feb 18, 2026

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.

Screenshot 2026-02-18 at 3 18 46 PM

Added fix for multi-shipment as well:

Screenshot 2026-02-18 at 4 04 51 PM

Caveats:

  • Editing from a valid state (i.e., a state with delivery options) -> invalid state (i.e., a state with no delivery options), for both single-shipment and multi-shipment (as long as we have 1 valid shipment, that’s gonna create a shipping method already)…
  • Switching from bopis -> delivery, then shipping method will auto-populate
    Both of these are happening in https://pwa-kit.mobify-storefront.com/ (traditional checkout) as well.

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • Modify logic to correctly display error toast for non-applicable shipping method for both single- and multi-shipment delivery orders
  • Update error text

How to Test-Drive This PR

  • Choose a state that does not have an applicable (non-pickup) shipping method for a delivery order (single and multi-shipment orders)
  • The error toast should be displayed at the top right
  • Changing the address to a state with a valid/applicable shipping method would resolve the issue

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

Signed-off-by: d.phan <d.phan@salesforce.com>
@dannyphan2000 dannyphan2000 requested review from a team as code owners February 18, 2026 20:15
Signed-off-by: d.phan <d.phan@salesforce.com>
onSuccess: (data) => {
const noMethods =
!data?.applicableShippingMethods || data.applicableShippingMethods.length === 0
const deliveryOnly = getDeliveryShippingMethods(data?.applicableShippingMethods)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only display shipping methods for delivery/shipping orders.

@cc-prodsec
Copy link
Collaborator

cc-prodsec commented Feb 18, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change to Cart page I mentioned @patricksullivansf

Signed-off-by: d.phan <d.phan@salesforce.com>
Copy link
Contributor

@patricksullivansf patricksullivansf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me. I had some complexity concerns for you to consider. no blockers.

Comment on lines +56 to +58
const hasMultipleDeliveryShipments = deliveryShipments.length > 1
const [isMultiShipping, setIsMultiShipping] = useState(hasMultipleDeliveryShipments)
const [openedByUser, setOpenedByUser] = useState(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

}

const ShipmentMethods = ({shipment, index, currency}) => {
const ShipmentMethods = ({shipment, index, currency, onShipmentMethodsResolved}) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: onShipmentMethodsResolved seems unnecessarily complicated.

Also, is this a breaking change to the component contract?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

dannyphan2000 and others added 7 commits February 25, 2026 17:53
Signed-off-by: d.phan <d.phan@salesforce.com>
…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>
syadupathi-sf
syadupathi-sf previously approved these changes Feb 27, 2026
if (wasMulti && !hasMultipleDeliveryShipments) {
return
}
if (step === STEPS.SHIPPING_OPTIONS) return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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>
syadupathi-sf
syadupathi-sf previously approved these changes Mar 2, 2026
shethj
shethj previously approved these changes Mar 2, 2026
Signed-off-by: d.phan <d.phan@salesforce.com>
Signed-off-by: d.phan <d.phan@salesforce.com>
@dannyphan2000 dannyphan2000 merged commit 927689e into develop Mar 2, 2026
42 checks passed
@dannyphan2000 dannyphan2000 deleted the dannyphan2000.W-21294742.error-no-shipping-method-fix branch March 2, 2026 23:41
rasbhat pushed a commit that referenced this pull request Mar 5, 2026
* @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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants