Add Subscription Product Helpers/Abstractions - #854
Draft
agibson-godaddy wants to merge 3 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
SubscriptionProductHelperto the framework that centralizes subscription-product detection ("does this product have a subscription?") and detail lookups (period, length, trial, sign-up fee, expiration date), so plugins get correct answers whether a store is running legacy WooCommerce Subscriptions product types or WC Subscriptions 9.0+'s bundled "subscription scheme" mechanism.Story: MWC-20234
Release: #853
Details
WC Subscriptions 9.0 merged "All Products for Subscriptions" (APFS) into core, adding a second way to sell a subscription: any Simple/Variable/etc. product can carry one or more subscription "schemes" without changing its product type. The existing
WC_Subscriptions_Product::is_subscription()(and its sibling getters) only ever check the legacy product-type path, so a scheme-based product silently reports as "not a subscription" wherever that method is used on its own — this is the root cause behind MWC-20228 in WooCommerce Memberships.Rather than fixing this as a one-off in Memberships, this PR moves the generic detection/read logic into the framework so any plugin built on it benefits:
Includes unit test coverage for both mechanisms and the scheme fallback behavior (active → default → base scheme).
QA
TODO - test with memberships