-
Notifications
You must be signed in to change notification settings - Fork 56
Cross browser AppSwitch #3569
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
Cross browser AppSwitch #3569
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @AlexP11223, thanks for working on this!
I added some comments, and I have a couple of questions:
- What happens if the EarlyOrderHandler is enabled? Wouldn't we end up with 2 orders?
- If the user is authenticated, will the order be associated with that user upon returning from AppSwitch on a different browser?
configure_customer
just sets the current user ID, which will be 0, so it seems that there won't be an association
modules/ppcp-button/resources/js/modules/OnApproveHandler/onApproveForPayNow.js
Show resolved
Hide resolved
I think EarlyOrderHandler is not creating anything? It only adds a hook handler to set some meta. For authenticated users as I understand currently AppSwitch will not trigger at all. But should be possible to save the customer id too. However then WC will ask to log in or enter the email to access the order pay page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this Alex. LGTM
@AlexP11223 AppSwitch does trigger for authenticated users. AFAIK PayPal expects the order to be associated with the customer account in the cross browser flow |
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. 🔗 Test this pull request with WordPress Playground What's included:
Login credentials:
Plugin Details:
🤖 Auto-generated for commit 2cb2758 • Last updated: 2025-08-25T05:35:59.943Z |
…4992-cross-browser-appswitch
Added handling of cross-browser AppSwitch (started in non-default browser, then redirected to the default one).
We save the current cart + PayPal order ID into transient before going to PayPal and add the transient key into the return URL, then after returning we retrieve the saved cart and PayPal order, create a WC order and redirect to Pay for order.
The WC order creation is done using the existing
WooCommerceOrderCreator
, refactored to useCartData
instead of the current WC cart.I had to change the
woocommerce_paypal_payments_shipping_callback_woocommerce_order_created
hook parameters. I hope it was used only internally 🤔 And renamed it towoocommerce_paypal_payments_woocommerce_order_created_from_cart
, so that at least nothing crashes, and because it's not just the shipping callback.Remaining issues: