Skip to content

feat(audience): subscription products (Plans) wizard#464

Open
miguelpeixe wants to merge 12 commits into
mainfrom
feat/audience-plans-ui
Open

feat(audience): subscription products (Plans) wizard#464
miguelpeixe wants to merge 12 commits into
mainfrom
feat/audience-plans-ui

Conversation

@miguelpeixe

Copy link
Copy Markdown
Member

All Submissions:

Changes proposed in this Pull Request:

Adds a new "Plans" management page under Audience — a DataViews UI for managing WooCommerce Subscriptions products: name, price + billing period, active-subscriber counts, category, status, variations, group/multi-seat subscriptions, and content unlocks. List, create, and edit subscription products without leaving the wizard.

The page is gated behind the NEWSPACK_PLANS_UI feature flag and only registers when WooCommerce Subscriptions is active. It shows the plain product price — the dynamic-pricing "effective price" overlay is intentionally a separate PR (the integration), so this PR has zero dependency on the dynamic-pricing engine.

First of a three-way split of feat/rsm-pricing-rules-dataviews: (1) Plans (this PR), (2) Pricing Rules wizard, (3) the engine-pricing integration onto Plans. PRs 1 and 2 are independent; PR 3 stacks on this one.

How to test the changes in this Pull Request:

  1. Add define( 'NEWSPACK_PLANS_UI', true ); to wp-config.php on a site with WooCommerce Subscriptions active.
  2. Go to Audience — a Plans submenu appears. Without the flag (or without WC Subscriptions) it does not register.
  3. The list shows subscription products with price/period, active-subscriber counts, category, and status. Create a new product and edit an existing one; confirm variations, group-subscription (multi-seat) settings, and content unlocks save correctly.
  4. Confirm prices shown are the plain product price — there is no dynamic-pricing/effective-price column in this PR.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

Copilot AI review requested due to automatic review settings June 30, 2026 15:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Audience → Plans wizard screen (gated by NEWSPACK_PLANS_UI and WooCommerce Subscriptions availability) that provides a DataViews-based UI for listing, creating, and editing WooCommerce subscription products (including variable and grouped “plan bundle” products, plus one-time donation products).

Changes:

  • Registers a new Audience wizard route/component (newspack-audience-subscription-products) and conditionally boots it via NEWSPACK_PLANS_UI.
  • Implements the Plans UI in React (DataViews list + routed create/edit form) with minimal scoped styling.
  • Adds a new PHP wizard + REST API layer to fetch the consolidated product model and create/update products.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
plugins/newspack-plugin/src/wizards/index.tsx Registers the new wizard entrypoint for Plans.
plugins/newspack-plugin/src/wizards/audience/views/subscription-products/index.tsx Adds the Plans wizard container and routes (list/new/edit).
plugins/newspack-plugin/src/wizards/audience/views/subscription-products/list.tsx Implements the DataViews list, scopes, filters, and row actions.
plugins/newspack-plugin/src/wizards/audience/views/subscription-products/product-edit.tsx Adds the routed wrapper that loads context and renders the form.
plugins/newspack-plugin/src/wizards/audience/views/subscription-products/product-form.tsx Implements the full-page create/edit form and save behavior.
plugins/newspack-plugin/src/wizards/audience/views/subscription-products/types.d.ts Adds ambient TS types for the Plans page response/model.
plugins/newspack-plugin/src/wizards/audience/views/subscription-products/style.scss Adds minimal scoped styles for chips/forms/badges layout.
plugins/newspack-plugin/src/wizards/audience/views/subscription-products/README.md Documents the new Plans UI/data model (needs alignment with current PR).
plugins/newspack-plugin/includes/wizards/audience/class-audience-subscription-products.php Adds the wizard + REST endpoints and product prep/create/update logic.
plugins/newspack-plugin/includes/class-wizards.php Conditionally registers the new wizard behind feature flag + WCS availability.
plugins/newspack-plugin/includes/class-newspack.php Includes the new wizard PHP class file.

@miguelpeixe

Copy link
Copy Markdown
Member Author

Addressed Copilot's review in 2ec87255c:

  • product-edit.tsx redirect during render — moved into a useEffect so render stays pure (StrictMode-safe).
  • subscription-products.php translated term names — switched to locale-independent default term names; UI labels stay translated separately.
  • get_active_subscription_count() N+1 wcs_get_subscriptions() — added a per-request memo of subscription-id lists, keyed by product id, so repeated/aggregated ids resolve once.
  • README.md stale "RSM prototype / Not for PR to main" header — rewritten to the shipped Plans reality.
  • No Plans-specific PHPUnit tests for the create/update REST endpoints — acknowledged. Worthwhile as a follow-up: this PR reconstructs an existing branch with no upstream Plans tests, so REST-endpoint coverage is better scoped on its own rather than bundled here.

@miguelpeixe miguelpeixe marked this pull request as ready for review July 2, 2026 16:15
@miguelpeixe miguelpeixe requested a review from a team as a code owner July 2, 2026 16:15
@miguelpeixe miguelpeixe self-assigned this Jul 2, 2026
@miguelpeixe miguelpeixe requested a review from dkoo July 2, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants