Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
80 stars 29 forks source link

Introduce filter to prevent automatic activation upon payment. #578

Closed peterwilsoncc closed 3 months ago

peterwilsoncc commented 3 months ago

Description

This comes out of adding subscription support to the Pre-orders extension, see https://github.com/woocommerce/woocommerce-pre-orders/issues/393 and the associated PR https://github.com/woocommerce/woocommerce-pre-orders/pull/497

Subscriptions automatically activates a subscription and set the start date to the current time upon payment. For standard orders this is expected. This occurs within WC_Subscriptions_Order::maybe_record_subscription_payment().

In the case of Pre-orders that are paid upfront, it activates a subscription prior to the product being available. As a result the recurring payments begin after the selected time frame, this too may be before the product is available.

In order to prevent a subscription from activating prior to the products availability, it would be helpful to introduce a filter allowing plugins to override it.

Pull request incoming

Testing instructions

  1. Check out the Subscriptions compat branch from https://github.com/woocommerce/woocommerce-pre-orders/pull/497
  2. Build JavaScript npm i; npm run build:dev
  3. Create a pre-ordered subscription product with upfront payments
  4. Order the product
  5. In the dashboard, observe the start and renewal date are based on the time of order rather than the pre-order start date

Product impact

Dev notes

Additional context