Flexible Subscriptions – Fatal TypeError
-
Hi WPDesk Support Team,
I’m experiencing a critical (fatal) error on my WooCommerce store when using Flexible Subscriptions alongside WooCommerce Payments (WooPayments). The error occurs every time I try to view or edit a subscription order in the WordPress admin panel. Environment
- WordPress: latest version
- WooCommerce: 10.5.1
- Flexible Subscriptions: latest version (free)
- WooCommerce Payments (WooPayments): latest version
- PHP: 8.4
Error Description
The method
WC_Payments_Subscription_Service::is_wcpay_subscription()expects an argument of typeWC_Subscription, but receivesWPDesk\FlexibleSubscriptions\Subscription\Subscriptioninstead. This causes an uncaughtTypeErrorand crashes the admin order/subscription edit page. Error Log (anonymized)Uncaught TypeError: WC_Payments_Subscription_Service::is_wcpay_subscription(): Argument #1 ($subscription) must be of type WC_Subscription, WPDesk\FlexibleSubscriptions\Subscription\Subscription given, called in .../wp-content/plugins/woocommerce-payments/includes/subscriptions/class-wc-payments-subscription-service.php on line 703 and defined in .../wp-content/plugins/woocommerce-payments/includes/subscriptions/class-wc-payments-subscription-service.php:287Backtrace (anonymized)
#0 .../woocommerce-payments/includes/subscriptions/class-wc-payments-subscription-service.php(703): WC_Payments_Subscription_Service::is_wcpay_subscription() #1 .../wp-includes/class-wp-hook.php(343): WC_Payments_Subscription_Service->prevent_wcpay_manual_renewal() #2 .../wp-includes/plugin.php(205): WP_Hook->apply_filters() #3 .../woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-actions.php(227): apply_filters() #4 .../woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-actions.php(37): WC_Meta_Box_Order_Actions::get_available_order_actions_for_order() #5 .../wp-admin/includes/template.php(1453): WC_Meta_Box_Order_Actions::output() #6 .../woocommerce/src/Internal/Admin/Orders/Edit.php(502): do_meta_boxes() #7 .../woocommerce/src/Internal/Admin/Orders/Edit.php(410): Automattic\WooCommerce\Internal\Admin\Orders\Edit->render_meta_boxes() #8 .../woocommerce/src/Internal/Admin/Orders/PageController.php(295): Automattic\WooCommerce\Internal\Admin\Orders\Edit->display()Steps to Reproduce
- Install and activate both Flexible Subscriptions and WooCommerce Payments.
- Create a subscription product using Flexible Subscriptions.
- Place a test subscription order.
- Go to WooCommerce → Orders and try to edit/view the subscription order.
- The page crashes with the fatal TypeError shown above.
Root Cause Analysis
It appears that WooCommerce Payments hooks into the
woocommerce_order_actionsfilter via itsprevent_wcpay_manual_renewal()method (line 703 ofclass-wc-payments-subscription-service.php). This method callsis_wcpay_subscription(), which has a strict type hint expectingWC_Subscription. However, Flexible Subscriptions passes its ownWPDesk\FlexibleSubscriptions\Subscription\Subscriptionobject, which does not extendWC_Subscription, causing the fatal error. Expected BehaviorFlexible Subscriptions should be compatible with WooCommerce Payments without causing fatal errors. The Subscription object should either extend
WC_Subscriptionor be filtered out before being passed to WooCommerce Payments hooks. Actual BehaviorA fatal
TypeErroris thrown, making it impossible to manage subscription orders in the admin panel. ImpactThis is a critical issue — the admin order edit screen is completely broken for any subscription created with Flexible Subscriptions when WooCommerce Payments is active. This blocks day-to-day store management.
I would appreciate it if you could look into this and provide a fix or a recommended workaround. Thank you for your time.
Best regards
You must be logged in to reply to this topic.