mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Ensure WooCommerce Subscriptions plugin functions exist
This commit is contained in:
parent
895cc486d4
commit
26c9733181
5 changed files with 13 additions and 6 deletions
|
@ -81,7 +81,7 @@ class BillingSubscriptionCancelled implements RequestHandler {
|
|||
),
|
||||
),
|
||||
);
|
||||
$subscriptions = wcs_get_subscriptions( $args );
|
||||
$subscriptions = function_exists( 'wcs_get_subscriptions' ) ? wcs_get_subscriptions( $args ) : array();
|
||||
foreach ( $subscriptions as $subscription ) {
|
||||
$subscription->update_status( 'cancelled' );
|
||||
}
|
||||
|
|
|
@ -71,10 +71,13 @@ class PaymentSaleCompleted implements RequestHandler {
|
|||
return $this->failure_response();
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wcs_get_subscriptions' ) ) {
|
||||
return $this->failure_response( 'WooCommerce Subscriptions plugin is not active.' );
|
||||
}
|
||||
|
||||
$billing_agreement_id = wc_clean( wp_unslash( $request['resource']['billing_agreement_id'] ?? '' ) );
|
||||
if ( ! $billing_agreement_id ) {
|
||||
$message = 'Could not retrieve billing agreement id for subscription.';
|
||||
return $this->failure_response( $message );
|
||||
return $this->failure_response( 'Could not retrieve billing agreement id for subscription.' );
|
||||
}
|
||||
|
||||
$args = array(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue