Skip to content

fix: PayPal Express rule-based shipping methods not switched on country changed#664

Open
Chuc Le (untilu29) wants to merge 1 commit into
trunkfrom
fix/paypal-express-rule-based-shipping
Open

fix: PayPal Express rule-based shipping methods not switched on country changed#664
Chuc Le (untilu29) wants to merge 1 commit into
trunkfrom
fix/paypal-express-rule-based-shipping

Conversation

@untilu29
Copy link
Copy Markdown

@untilu29 Chuc Le (untilu29) commented May 12, 2026

1. Why is this change necessary?

When the buyer changes the delivery country in the PayPal Express popup, the shipping callback switched the sales channel context to the new country but kept the previously selected shipping method ID. If that method was restricted by a country rule, the cart picked up a ShippingMethodBlockedError and the callback hard-failed with EXPRESS_SHIPPING_CALLBACK_METHOD_UNAVAILABLE - even when another shipping method was available for the new country

2. What does this change do, exactly?

After the context switch, if the cart now has a ShippingMethodBlockedError and ShippingOptionsProvider returns an available alternative, switch the context to the first available method and recalculate the cart so PayPal sees a valid selection

Also guard ExpressCustomerService::getAddressData against Shipping::$name being uninitialized — PayPal occasionally returns a Shipping struct without a name (e.g., in local-development mode), which caused a TypeError on the typed property access

3. Describe each step to reproduce the issue or behaviour.

4. Please link to the relevant issues (if any).

5. Checklist

  • I have written tests and verified that they fail without my change
  • I have created an entry in the CHANGELOG.md files with all necessary user information about my changes
  • This change has comments for package types, values, functions, and non-obvious lines of code
  • I have read the contribution requirements and fulfill them.

@untilu29 Chuc Le (untilu29) force-pushed the fix/paypal-express-rule-based-shipping branch from 9c8b60c to 2b44131 Compare May 12, 2026 10:30
@untilu29 Chuc Le (untilu29) requested a review from a team May 12, 2026 11:17
@untilu29 Chuc Le (untilu29) marked this pull request as ready for review May 12, 2026 11:17
@untilu29 Chuc Le (untilu29) self-assigned this May 12, 2026
Comment thread src/Checkout/ExpressCheckout/Service/ExpressCustomerService.php Outdated
@mstegmeyer
Copy link
Copy Markdown
Contributor

Not sure if we need this whole Shipping name fallback. AFAIK this was a Sandbox fluke a few days ago and not really something we should expect.

@untilu29 Chuc Le (untilu29) force-pushed the fix/paypal-express-rule-based-shipping branch from 2b44131 to 2f3d3c2 Compare May 13, 2026 04:21
@untilu29 Chuc Le (untilu29) changed the title fix: PayPal Express rule-based shipping methods not switched on counttry changed fix: PayPal Express rule-based shipping methods not switched on country changed May 14, 2026
@untilu29 Chuc Le (untilu29) requested a review from a team May 15, 2026 03:43
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.

3 participants