Closed peterwilsoncc closed 3 months ago
Is the main reason for this new filter to prevent Woo Subscriptions activating the subscription due to the parent order having a completed status?
Yes, that's the main reason for the proposed filter.
So perhaps a slightly different approach would be to introduce a filter like
wcs_is_subscription_order_completed
which filters the$order_completed
variable so third-parties hooking into it only have a very specific condition they're filtering and not the entire line including subscription is active and the rest.Thoughts?
That works for me, in terms of parameters the filter would receive, I think they'd be:
bool $order_completed
string $new_order_status
string $old_order_status // I don't think pre-orders will need this but included for consistency
WC_Subscription $subscription
int $order_id
Thanks @mattallan I've committed the version number change.
No need to apologise for taking a few days to get around to this, I appreciate the promptness.
Fixes #578
Description
Edited following discussion below with Matt
Introduces a new filter within
WC_Subscriptions_Order::maybe_record_subscription_payment()
to allow third party extensions to prevent subscriptions from being marked as completed and activated following payment. This is to account for statuses that WooCommerce Core needs to consider the main order completed but the subscription remains in progress.This is to assist with pre-order support of subscription with upfront payments and to prevent renewals before the product has been released.
In pre-orders it was considered to simply remove the filter registered by subscriptions (
remove_action( 'woocommerce_order_status_changed', 'WC_Subscriptions_Order::maybe_record_subscription_payment', 9, 3 );
) but I though that had a greater risk of unintended side-effects for unrelated subscription products.How to test this PR
Product impact