mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Merge pull request #1650 from woocommerce/PCP-1968-subscriptions-api-renewals
PayPal Subscriptions API renewals (1968)
This commit is contained in:
commit
2961132aec
2 changed files with 51 additions and 17 deletions
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\Subscription;
|
||||
|
||||
use ActionScheduler_Store;
|
||||
use Exception;
|
||||
use WC_Product;
|
||||
use WC_Product_Subscription_Variation;
|
||||
|
@ -288,6 +289,35 @@ class SubscriptionModule implements ModuleInterface {
|
|||
30,
|
||||
2
|
||||
);
|
||||
|
||||
add_action(
|
||||
'action_scheduler_before_execute',
|
||||
/**
|
||||
* Param types removed to avoid third-party issues.
|
||||
*
|
||||
* @psalm-suppress MissingClosureParamType
|
||||
*/
|
||||
function( $action_id ) {
|
||||
/**
|
||||
* Class exist in WooCommerce.
|
||||
*
|
||||
* @psalm-suppress UndefinedClass
|
||||
*/
|
||||
$store = ActionScheduler_Store::instance();
|
||||
$action = $store->fetch_action( $action_id );
|
||||
|
||||
$subscription_id = $action->get_args()['subscription_id'] ?? null;
|
||||
if ( $subscription_id ) {
|
||||
$subscription = wcs_get_subscription( $subscription_id );
|
||||
if ( is_a( $subscription, WC_Subscription::class ) ) {
|
||||
$paypal_subscription_id = $subscription->get_meta( 'ppcp_subscription' ) ?? '';
|
||||
if ( $paypal_subscription_id ) {
|
||||
as_unschedule_action( $action->get_hook(), $action->get_args() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -527,7 +557,8 @@ class SubscriptionModule implements ModuleInterface {
|
|||
$subscriptions_api_handler = $c->get( 'subscription.api-handler' );
|
||||
assert( $subscriptions_api_handler instanceof SubscriptionsApiHandler );
|
||||
$this->update_subscription_product_meta( $product, $subscriptions_api_handler );
|
||||
}
|
||||
},
|
||||
30
|
||||
);
|
||||
|
||||
add_action(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue