woocommerce / woocommerce-gateway-paypal-express-checkout

58 stars 65 forks source link

Don't always redirect the customer to the cart page after closing PayPal modal #765

Closed mattallan closed 4 years ago

mattallan commented 4 years ago

Issue: #757


Description

In 2.0 we changed the behaviour so that when a customer closes/cancels the PayPal modal they're now always redirected to the cart page.

There are a few instances where this change feels a bit odd from a customer's perspective. Some examples:

This also feels a bit weird if your store doesn't use a cart page (i.e. empty Cart page in WooCommerce > Settings > Advanced) and customers are redirected back to stores home page.

Looking at 1.6.21, when you closed/cancelled the PayPal modal, you would land back the same page which feels a bit more natural.

In this PR, I'm passing an empty cancel_url and have updated the onCancel handler so that we will now only redirect the customer to a cancel_url if it's set using the woocommerce_paypal_express_checkout_payment_button_data filter.

The default behaviour will now return the customer back to the same page they clicked on the PayPal Buttons (as per in 1.6.21 and previous versions)

Steps to test:

  1. Visit a product page
  2. Click on the PayPal button
  3. Close the pop-up window
  4. On master, redirected to the cart page
  5. On this branch, redirected back to the product page.

Documentation

Closes #757 .

james-allan commented 4 years ago

LGTM 👍