Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh page when ECE is dismissed #9888

Merged
merged 35 commits into from
Dec 17, 2024

Conversation

rafaelzaleski
Copy link
Contributor

@rafaelzaleski rafaelzaleski commented Dec 5, 2024

Fixes #9794

Changes proposed in this Pull Request

Refresh the page's shipping information when ECE is dismissed. This ensures that the shipping options on the cart and checkout pages are updated without requiring the user to reload the page.

Testing Instructions

Repeat the following steps for:

  • Cart and Checkout pages.
  • Shortcode and Blocks versions of these pages.
  • Google Pay and Apple Pay.
  1. Add products to your cart that require shipping.
  2. Navigate to the page under test (cart or checkout).
  3. Click on the express payment method you are testing (Apple Pay or Google Pay).
  4. Select a shipping address in the payment sheet.
  5. Close the payment sheet without completing the payment.
  6. Verify that the shipping address and shipping rates on the page are updated to reflect the selected address.
  7. Reload the page and confirm that the shipping information remains the same as in the previous step.

  • Run npm run changelog to add a changelog file, choose patch to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.
  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Post merge

@rafaelzaleski rafaelzaleski self-assigned this Dec 5, 2024
@botwoo
Copy link
Collaborator

botwoo commented Dec 5, 2024

Test the build

Option 1. Jetpack Beta

  • Install and activate Jetpack Beta.
  • Use this build by searching for PR number 9888 or branch name fix/9794-refresh-page-when-ece-dismissed in your-test.site/wp-admin/admin.php?page=jetpack-beta&plugin=woocommerce-payments

Option 2. Jurassic Ninja - available for logged-in A12s

🚀 Launch a JN site with this branch 🚀

ℹ️ Install this Tampermonkey script to get more options.


Build info:

  • Latest commit: 9dd5e1d
  • Build time: 2024-12-17 18:02:34 UTC

Note: the build is updated when a new commit is pushed to this PR.

@rafaelzaleski rafaelzaleski changed the title Refresh page when ECE is dismissed WIP: Refresh page when ECE is dismissed Dec 5, 2024
Copy link
Contributor

github-actions bot commented Dec 5, 2024

Size Change: +48.3 kB (+4%)

Total Size: 1.39 MB

Filename Size Change
release/woocommerce-payments/dist/blocks-checkout.js 55.1 kB +368 B (+1%)
release/woocommerce-payments/dist/express-checkout.js 15.4 kB +305 B (+2%)
release/woocommerce-payments/dist/index-rtl.css 52.6 kB -176 B (0%)
release/woocommerce-payments/dist/index.css 52.6 kB -176 B (0%)
release/woocommerce-payments/dist/index.js 302 kB +88 B (0%)
release/woocommerce-payments/dist/tokenized-express-checkout.js 15.9 kB +14 B (0%)
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/react-jsx-runtime.js 0 B -553 B (removed) 🏆
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/identity-crisis.css 2.47 kB +22 B (+1%)
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/identity-crisis.js 14.2 kB -55 B (0%)
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/identity-crisis.rtl.css 2.47 kB +20 B (+1%)
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-users.js 424 B +7 B (+2%)
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-callables.js 585 B +1 B (0%)
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-users.js 632 B +11 B (+2%)
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-connection.css 10 kB +10 kB (new file) 🆕
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-connection.js 28.4 kB +28.4 kB (new file) 🆕
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-connection.rtl.css 10 kB +10 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 1.37 kB
release/woocommerce-payments/assets/css/admin.rtl.css 1.37 kB
release/woocommerce-payments/assets/css/success.css 182 B
release/woocommerce-payments/assets/css/success.rtl.css 184 B
release/woocommerce-payments/dist/blocks-checkout-rtl.css 2.63 kB
release/woocommerce-payments/dist/blocks-checkout.css 2.63 kB
release/woocommerce-payments/dist/cart-block.js 17 kB
release/woocommerce-payments/dist/cart.js 5.73 kB
release/woocommerce-payments/dist/checkout-rtl.css 932 B
release/woocommerce-payments/dist/checkout.css 931 B
release/woocommerce-payments/dist/checkout.js 33.4 kB
release/woocommerce-payments/dist/express-checkout-rtl.css 229 B
release/woocommerce-payments/dist/express-checkout.css 229 B
release/woocommerce-payments/dist/frontend-tracks.js 854 B
release/woocommerce-payments/dist/multi-currency-analytics.js 1.08 kB
release/woocommerce-payments/dist/multi-currency-rtl.css 4.46 kB
release/woocommerce-payments/dist/multi-currency-switcher-block.js 60.6 kB
release/woocommerce-payments/dist/multi-currency.css 4.46 kB
release/woocommerce-payments/dist/multi-currency.js 57.3 kB
release/woocommerce-payments/dist/order-rtl.css 730 B
release/woocommerce-payments/dist/order.css 730 B
release/woocommerce-payments/dist/order.js 42 kB
release/woocommerce-payments/dist/payment-gateways-rtl.css 1.32 kB
release/woocommerce-payments/dist/payment-gateways.css 1.32 kB
release/woocommerce-payments/dist/payment-gateways.js 38.4 kB
release/woocommerce-payments/dist/plugins-page-rtl.css 386 B
release/woocommerce-payments/dist/plugins-page.css 386 B
release/woocommerce-payments/dist/plugins-page.js 20.1 kB
release/woocommerce-payments/dist/product-details-rtl.css 433 B
release/woocommerce-payments/dist/product-details.css 436 B
release/woocommerce-payments/dist/product-details.js 12.3 kB
release/woocommerce-payments/dist/settings-rtl.css 11.6 kB
release/woocommerce-payments/dist/settings.css 11.5 kB
release/woocommerce-payments/dist/settings.js 224 kB
release/woocommerce-payments/dist/subscription-edit-page.js 703 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal-rtl.css 524 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 524 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 20.2 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 730 B
release/woocommerce-payments/dist/subscriptions-empty-state-rtl.css 120 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 120 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 19.3 kB
release/woocommerce-payments/dist/tokenized-express-checkout-rtl.css 229 B
release/woocommerce-payments/dist/tokenized-express-checkout.css 229 B
release/woocommerce-payments/dist/tos-rtl.css 235 B
release/woocommerce-payments/dist/tos.css 235 B
release/woocommerce-payments/dist/tos.js 21.8 kB
release/woocommerce-payments/dist/woopay-direct-checkout.js 6.13 kB
release/woocommerce-payments/dist/woopay-express-button.js 24.8 kB
release/woocommerce-payments/dist/woopay-rtl.css 4.31 kB
release/woocommerce-payments/dist/woopay.css 4.28 kB
release/woocommerce-payments/dist/woopay.js 71 kB
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 625 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 814 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/i18n-loader.js 2.46 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/jetpack-script-data.js 767 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/i18n-loader.js 1.02 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/script-data.js 69 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/babel.config.js 163 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.css 198 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.js 280 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.rtl.css 198 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.css 625 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.js 333 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.rtl.css 626 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-ajax.js 521 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-admin-create-user.css 215 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-admin-create-user.js 521 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-login.css 721 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-login.js 412 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/about.css 1.04 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-empty-state.css 294 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-order-statuses.css 408 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin.css 3.59 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/checkout.css 301 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/modal.css 746 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/view-subscription.css 574 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/wcs-upgrade.css 414 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin-pointers.js 543 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin.js 9.4 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.js 6.78 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.min.js 3.84 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-coupon.js 545 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-subscription.js 2.52 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.js 22.2 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.min.js 11.7 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/payment-method-restrictions.js 1.29 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/wcs-meta-boxes-order.js 507 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/payment-methods.js 358 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/single-product.js 428 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/view-subscription.js 1.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/wcs-cart.js 782 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/modal.js 1.09 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/wcs-upgrade.js 1.26 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.css 391 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.js 3.04 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Dec 16, 2024

Size Change: +1.21 kB (0%)

Total Size: 1.39 MB

Filename Size Change
release/woocommerce-payments/dist/blocks-checkout.js 55.3 kB +434 B (+1%)
release/woocommerce-payments/dist/express-checkout.js 15.5 kB +323 B (+2%)
release/woocommerce-payments/dist/tokenized-express-checkout.js 16.3 kB +449 B (+3%)
ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 1.37 kB
release/woocommerce-payments/assets/css/admin.rtl.css 1.37 kB
release/woocommerce-payments/assets/css/success.css 182 B
release/woocommerce-payments/assets/css/success.rtl.css 184 B
release/woocommerce-payments/dist/blocks-checkout-rtl.css 2.63 kB
release/woocommerce-payments/dist/blocks-checkout.css 2.63 kB
release/woocommerce-payments/dist/cart-block.js 17 kB
release/woocommerce-payments/dist/cart.js 5.73 kB
release/woocommerce-payments/dist/checkout-rtl.css 932 B
release/woocommerce-payments/dist/checkout.css 931 B
release/woocommerce-payments/dist/checkout.js 33.4 kB
release/woocommerce-payments/dist/express-checkout-rtl.css 229 B
release/woocommerce-payments/dist/express-checkout.css 229 B
release/woocommerce-payments/dist/frontend-tracks.js 854 B
release/woocommerce-payments/dist/index-rtl.css 52.6 kB
release/woocommerce-payments/dist/index.css 52.6 kB
release/woocommerce-payments/dist/index.js 302 kB
release/woocommerce-payments/dist/multi-currency-analytics.js 1.08 kB
release/woocommerce-payments/dist/multi-currency-rtl.css 4.46 kB
release/woocommerce-payments/dist/multi-currency-switcher-block.js 60.6 kB
release/woocommerce-payments/dist/multi-currency.css 4.46 kB
release/woocommerce-payments/dist/multi-currency.js 57.3 kB
release/woocommerce-payments/dist/order-rtl.css 730 B
release/woocommerce-payments/dist/order.css 730 B
release/woocommerce-payments/dist/order.js 42 kB
release/woocommerce-payments/dist/payment-gateways-rtl.css 1.32 kB
release/woocommerce-payments/dist/payment-gateways.css 1.32 kB
release/woocommerce-payments/dist/payment-gateways.js 38.4 kB
release/woocommerce-payments/dist/plugins-page-rtl.css 386 B
release/woocommerce-payments/dist/plugins-page.css 386 B
release/woocommerce-payments/dist/plugins-page.js 20.1 kB
release/woocommerce-payments/dist/product-details-rtl.css 433 B
release/woocommerce-payments/dist/product-details.css 436 B
release/woocommerce-payments/dist/product-details.js 12.3 kB
release/woocommerce-payments/dist/settings-rtl.css 11.6 kB
release/woocommerce-payments/dist/settings.css 11.5 kB
release/woocommerce-payments/dist/settings.js 224 kB
release/woocommerce-payments/dist/subscription-edit-page.js 703 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal-rtl.css 524 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 524 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 20.2 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 730 B
release/woocommerce-payments/dist/subscriptions-empty-state-rtl.css 120 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 120 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 19.3 kB
release/woocommerce-payments/dist/tokenized-express-checkout-rtl.css 229 B
release/woocommerce-payments/dist/tokenized-express-checkout.css 229 B
release/woocommerce-payments/dist/tos-rtl.css 235 B
release/woocommerce-payments/dist/tos.css 235 B
release/woocommerce-payments/dist/tos.js 21.8 kB
release/woocommerce-payments/dist/woopay-direct-checkout.js 6.13 kB
release/woocommerce-payments/dist/woopay-express-button.js 24.8 kB
release/woocommerce-payments/dist/woopay-rtl.css 4.31 kB
release/woocommerce-payments/dist/woopay.css 4.28 kB
release/woocommerce-payments/dist/woopay.js 71 kB
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 625 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 814 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/i18n-loader.js 2.46 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/jetpack-script-data.js 767 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/i18n-loader.js 1.02 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/script-data.js 69 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/babel.config.js 163 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/identity-crisis.css 2.47 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/identity-crisis.js 14.2 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/identity-crisis.rtl.css 2.47 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-connection.css 10 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-connection.js 28.4 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-connection.rtl.css 10 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.css 198 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.js 280 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.rtl.css 198 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.css 625 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.js 333 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.rtl.css 626 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-users.js 424 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-ajax.js 521 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-callables.js 585 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-admin-create-user.css 215 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-admin-create-user.js 521 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-login.css 721 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-login.js 412 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-users.js 632 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/about.css 1.04 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-empty-state.css 294 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-order-statuses.css 408 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin.css 3.59 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/checkout.css 301 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/modal.css 746 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/view-subscription.css 574 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/wcs-upgrade.css 414 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin-pointers.js 543 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin.js 9.4 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.js 6.78 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.min.js 3.84 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-coupon.js 545 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-subscription.js 2.52 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.js 22.2 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.min.js 11.7 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/payment-method-restrictions.js 1.29 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/wcs-meta-boxes-order.js 507 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/payment-methods.js 358 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/single-product.js 428 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/view-subscription.js 1.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/wcs-cart.js 782 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/modal.js 1.09 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/wcs-upgrade.js 1.26 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.css 391 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.js 3.04 kB

compressed-size-action

@rafaelzaleski rafaelzaleski marked this pull request as ready for review December 16, 2024 14:17
@rafaelzaleski rafaelzaleski requested review from asumaran and frosso and removed request for a team December 16, 2024 14:28
Copy link
Contributor

@asumaran asumaran left a comment

Choose a reason for hiding this comment

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

@rafaelzaleski @pierorocca when using an address from the UK or Canada, the refresh doesn’t work correctly. It seems that for addresses in those countries, shipping methods cannot be calculated because the full zip code cannot be retrieved. It might be better to disable this new behavior for the UK, Canada, and any country where shipping options fail to load with the data provided by the payment sheet.

I also wanted to point out that the billing address is NOT being updated. If the customer has a previously saved address in the session, it remains unchanged even after updating the shipping address. While this might not be an issue, I thought it was worth mentioning to keep in mind.

Comment on lines 231 to 232
if ( ! [ 'cart', 'checkout' ].includes( context ) || ! lastSelectedAddress )
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add braces here?

@rafaelzaleski
Copy link
Contributor Author

@asumaran, I'm now bypassing GB and CA addresses. However, I noticed that these addresses are still being saved in the session with the redacted postcode when they fall under the "rest of the world" category. In this case, the postcode isn’t needed to calculate shipping options.

If the user refreshes the page, they’ll see the incorrect (redacted) address.

The issue is that the Blocks API won't accept a redacted postcode for calculating shipping options, which is why a live refresh isn’t possible for CA and UK addresses.

@pierorocca
Copy link
Contributor

pierorocca commented Dec 17, 2024

Asked on the Stripe slack channel if they know why the address is redacted and if that's expected. It's odd it only applied to some countries.

Copy link
Contributor

@asumaran asumaran left a comment

Choose a reason for hiding this comment

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

@rafaelzaleski I found a small discrepancy between the shortcode and block implementations. If the address is changed in the cart block page, it is correctly reflected on the cart page in both the block and shortcode pages.

However, on the shortcode Cart page, if we reopen the payment sheet and select the same address, the address changes once the dialog is closed. The state/county is removed. See the video for reference.

Screen.Recording.2024-12-16.at.7.38.38.PM.mov

So far, this behavior seems to occur with a 🇵🇪 Peruvian address only. Addresses in Brazil and the US appear to work correctly.

This can lead to unexpected behaviors** if we have specific rates for given city/county as it will appears the shipping options changes.

Here’s another video where the issue can be seen. In the payment sheet, the shipping rate shows $60, but after closing the payment sheet, the shipping rate changes to $5, which is the default rate for “Rest of the world” It should remain $60, which is the specific rate for “Municipalidad Metropolitana de Lima.”

Screen.Recording.2024-12-16.at.8.01.23.PM.mov

I think it’s worth looking into what’s going on.

Other than that I left a couple of small comments for you so far.

I haven't finished testing all the cases I wanted. I'll continue later.

if (
[ 'cart', 'checkout' ].includes( context ) &&
lastSelectedAddress &&
! [ 'CA', 'GB' ].includes( lastSelectedAddress.country )
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move this array, along with the accompanying comment, into a self-explanatory variable, either within this function or at a higher level? As this list will likely need to be updated with more countries in the future, using a variable name and relocating it would improve readability and maintainability.

if (
[ 'cart', 'checkout' ].includes( context ) &&
lastSelectedAddress &&
! [ 'CA', 'GB' ].includes( lastSelectedAddress.country )
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Let's put this array in a variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this mirrors the code in the other file, I’ll wait until we complete the review process before copying the changes over to tokenized carts. You can focus your review on the code outside tokenized carts for now.

Comment on lines 2 to 4
/**
* External dependencies
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious: is it necessary to include this “external dependencies” comment even if we’re not importing a single module?

@rafaelzaleski
Copy link
Contributor Author

Asked on the Stripe slack channel if they know why the address is redacted and if that's expected. It's odd it only applied to some countries.

@pierorocca, it looks like this is how Google Pay was implemented (reference). I don’t think Stripe has control over this behavior.

I believe the redacted version (showing only the first few digits) is sufficient to calculate shipping costs for a specific region, which is the purpose of the intermediate address. However, proper support for calculating rates with partial postcodes would need to be added in Woo Core. Right now, we’re just hacking a workaround for this.

@rafaelzaleski
Copy link
Contributor Author

So far, this behavior seems to occur with a 🇵🇪 Peruvian address only. Addresses in Brazil and the US appear to work correctly.

@asumaran, Peruvian states are coming through the payment sheet as full text instead of the abbreviated 3-letter code. I added a fallback to use the option text when the option value doesn’t match the payment sheet here: 08d18fc

Copy link
Contributor

@asumaran asumaran left a comment

Choose a reason for hiding this comment

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

Alright, I’ve tested this on the product, cart and checkout pages (both shortcode and block-based), and everything is working as expected.

The Peruvian address issue has been resolved.

However, the issue with addresses from countries affected by the zip code limitation still persists. Unfortunately, there’s not much we can do about it but the address isn’t refreshed as expected in those cases.

That said, I think the PR is good to go. Just make sure to apply the changes to the Tokenized Carts implementation. I’ve tested the happy path with the current changes, and it’s working fine there.

client/express-checkout/utils/shipping-fields.js Outdated Show resolved Hide resolved
* @return {boolean} True if the postcode is redacted for the country, false otherwise.
*/
const isPostcodeRedactedForCountry = ( country ) => {
return country.length === 2 && [ 'CA', 'GB' ].includes( country );
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, why are we checking the country name length here? Wouldn’t the .includes method be sufficient on its own?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was initially to ensure we're receiving an alpha-2 ISO code, but you’re right—it's redundant with the array check. I've removed it here.

@rafaelzaleski rafaelzaleski added this pull request to the merge queue Dec 17, 2024
Merged via the queue into develop with commit 129fe05 Dec 17, 2024
25 checks passed
@rafaelzaleski rafaelzaleski deleted the fix/9794-refresh-page-when-ece-dismissed branch December 17, 2024 18:54
@pierorocca
Copy link
Contributor

@pierorocca, it looks like this is how Google Pay was implemented (reference). I don’t think Stripe has control over this behavior.

I believe the redacted version (showing only the first few digits) is sufficient to calculate shipping costs for a specific region, which is the purpose of the intermediate address. However, proper support for calculating rates with partial postcodes would need to be added in Woo Core. Right now, we’re just hacking a workaround for this.

I'm a little worried that there's so much information missing if the shopper exits and checks out using the form. It's more likely than not that the shopper will submit and encounter validation errors. My question is how is Shopify able to do that with the same Google Pay integration? I'm asking Stripe anyway in case this happens to be a gated feature.

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.

Refresh cart/checkout page when ECE or PRBs are dismissed
4 participants