Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Uncaught Error: Call to undefined function wcs_get_subscriptions_for_order()" #29

Closed
rvdsteege opened this issue Nov 9, 2022 · 0 comments · Fixed by #30
Closed
Labels

Comments

@rvdsteege
Copy link
Member

It appears a fatal error can occur if WooCommerce Subscriptions is not active:

CRITICAL Uncaught Error: Call to undefined function wcs_get_subscriptions_for_order() in /wp-content/plugins/pronamic-ideal/vendor/wp-pay-extensions/woocommerce/src/Gateway.php:792

/**
* Connection subscription payment renewal.
*
* @param Payment $payment Payment.
* @param WC_Order $order WooCommerce order.
* @return void
*/
private function connect_subscription_payment_renewal( $payment, $order ) {
$woocommerce_subscriptions = \wcs_get_subscriptions_for_order( $order, [ 'order_type' => 'renewal' ] );
foreach ( $woocommerce_subscriptions as $woocommerce_subscription ) {
$subscription_helper = new SubscriptionHelper( $woocommerce_subscription );
$pronamic_subscription = $subscription_helper->get_pronamic_subscription();
if ( null !== $pronamic_subscription ) {
// Add subscription and period.
$payment->add_subscription( $pronamic_subscription );
$period = $pronamic_subscription->next_period();
if ( null !== $period ) {
$payment->add_period( $period );
}
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
1 participant