1

I have a site using WooCommerce Subscriptions. I do some processing in a woocommerce_available_payment_gateways($available_gateways) filter handler function and I need to detect if the checkout process was triggered by the user wanting to change their payment method for a subscription (woo user docs: https://woocommerce.com/document/subscriptions/customers-view/#section-11).

After a lot of Googling all I could come up with was this:

WC_Subscriptions_Change_Payment_Gateway::$is_request_to_change_payment;

This is a public static property on WC_Subscriptions_Change_Payment_Gateway, but it using it feels a bit nasty!

Does any one know of a cleaner way to do this?

-C

mujuonly
  • 11,370
  • 5
  • 45
  • 75
colin_froggatt
  • 147
  • 1
  • 10

1 Answers1

1

The URL for change payment gateway request will be looking like www.example.com/checkout/order-pay/1631818391/?pay_for_order=true&key=wc_order_3Qcv1jNShbWNt&change_payment_method=1631818391&_wpnonce=35a514c6ed. So isset() of $_GET['change_payment_method'] can be used in this context.

mujuonly
  • 11,370
  • 5
  • 45
  • 75