Closed rynaldos-zz closed 4 years ago
Hey @rynaldos,
Thanks for opening this issue.
In 2.0 we added a new onCancel
function handler to our PayPal Smart Buttons implementation.
We are then redirecting the user back to the cancel URL (the cart page) when the customer closes/cancels the PayPal form.
To answer your question, yes, this is working as intended, but why the cart page? I'm not 100% sure on this, but the cart page is what we use as the cancel URL in other areas of PayPal Checkout (see _get_cancel_url()
).
You can change this cancel URL by using the following filtering 'woocommerce_paypal_express_checkout_payment_button_data'
and changing the value of 'cancel_url'
in that array.
cc @jorgeatorres 👋 It looks like in 1.6.21, cancelling/closing the Paypal form would redirect the customer back to the same page they came from. In 2.0.0, we now redirect the customer to the cart page, but one issue I see with this is not every store has a cart page. For instance, if you don't have a cart page set in WooCommerce > Settings > Advanced the customer is redirected back to the home page which feels odd.
Is there a reason we have to set/use the onCancel
function?
Looking at the PayPal docs, if we don't have an onCancel
function, the customer is redirected back to the parent page by default which sounds like something we want.
Thoughts?
Hey @mattallan!
Is there a reason we have to set/use the onCancel function?
I don't think there's a reason other than maybe consistency with other areas of our codebase (as you have mentioned). If redirecting to the parent page makes more sense to most users (or for backwards compatibility with 1.6.x), I have nothing against changing the default behavior.
My only suggestion would be that we don't entirely remove 'cancel_url' from the button settings. Maybe we can use a default value of '' (meaning no onCancel
handler is used i.e. redirect to parent), but if a URL is configured via 'woocommerce_paypal_express_checkout_payment_button_data' we redirect to that particular URL passing the order ID in the querystring, as we currently do.
Would that make sense?
Howdy!
I am not entirely sure if this is the intended behavior or not, but was able to replicate the issue on the most recent version of WooCommerce core (v4.1.1), WordPress (v5.4.1), and PayPal Checkout (v2.0.2).
When on the checkout page, after clicking the payment button, a modal will pop up to continue the payment. At this point, close the modal window, and the user will automatically be redirected back to the cart page.
Reproducing:
Is this the intended behavior, and if so, why? If it isn't, is there a way to prevent the redirect from happening?
Cheers!