PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, November 11, 2022

[FIXED] How to detect if WooCommerce subscriptions checkout page is for a change payment gateway request?

 November 11, 2022     hook-woocommerce, payment-gateway, php, woocommerce, woocommerce-subscriptions     No comments   

Issue

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


Solution

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.



Answered By - mujuonly
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing