With Woo Subs: “Call to a member function get_customer_id() on null”
-
Howdy!
We had an error come up on one of our sites today, just wanted to let you know.
As far as we can tell it was triggered when someone tried to change their payment method for a Woo Subscriptions subscription from the WC customer subscription pages.
WP/Plugin versions:
- WP: 6.5.2
- Woo Subscriptions: 6.2.0
- WooCommerce: 8.7.0
- Payment Plugins for Stripe WooCommerce: 3.3.60
The error was:
Error Call to a member function get_customer_id() on null
The error came from:
woo-stripe-payment/includes/abstract/abstract-wc-payment-gateway-stripe.php:1901
Tracing back from that line, which is in
process_change_payment_method_request()
, it’s trying to call$token->get_customer_id()
on a$token
retrieved a couple lines ago for a WC Subscription.$this->get_token( $this->payment_method_token, $subscription->get_user_id() )
has returnednull
in this case, and there is no guarding against that possible value inprocess_change_payment_method_request()
In this customer’s particular case, there is no prior payment method as the subscription and parent order were created by a data importer – it’s possible this is resulting in the token not being retrieved.
For a solution, it might be possible to include the erroring line within the
if(){}
following just after it, though being the customer ID it might potentially be worth getting the customer from the order itself rather than the token?Cheers!
Dan
- The topic ‘With Woo Subs: “Call to a member function get_customer_id() on null”’ is closed to new replies.