Skip to content

fix(woocommerce): scope payment notice to recoverable statuses#301

Open
jason10lee wants to merge 7 commits into
mainfrom
hotfix/nppm-2926-payment-notice-status-allowlist
Open

fix(woocommerce): scope payment notice to recoverable statuses#301
jason10lee wants to merge 7 commits into
mainfrom
hotfix/nppm-2926-payment-notice-status-allowlist

Conversation

@jason10lee

@jason10lee jason10lee commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

All Submissions:

Changes proposed in this Pull Request:

Users continued to see the My Account / snackbar "Your '…' subscription is not active. Please update your payment method." notice following previous efforts to limit where it appeared.

This PR further limits that notice to subscriptions in a status where paying can actually restore them — on-hold (failed renewal) and pending (awaiting initial payment).

Previously we skipped only cancelled items and otherwise trusted needs_payment(). An expired (or otherwise terminal) subscription that still carries a stale, unpaid failed-renewal order trips needs_payment(), so finished subscriptions kept firing a notice the reader had no way to resolve — telling active subscribers they were "not active."

This replaces the cancelled-only skip with an explicit recoverable-status allowlist. expired / cancelled / switched (terminal) and active / pending-cancel (reader still has access) are intentionally excluded. A guard test pins the allowlist against the known WooCommerce Subscriptions status set so any future/custom status surfaces for a human decision rather than being silently skipped.

Scope: This is a hotfix that fully resolves the reported incident. A broader preventative adjustment that will suppress the notice when an active subscription grants the same membership through a different product (the "same product was too narrow" follow-up) will ship separately on our typical release cadence and is not included here.

Closes NPPM-2926: Update Payment Notice still fires for subscribers holding both active and expired subscriptions.

How to test the changes in this Pull Request:

  1. On a site with WooCommerce Subscriptions, take a reader who has both (a) an active subscription and (b) an expired subscription that still has an unpaid failed-renewal order (the newsroom.co.nz repro: expired sub #190664). Before this change, browsing the front end / My Account shows the "subscription is not active / update your payment method" notice.
  2. With this change applied, log in as (or impersonate) that reader and browse the front end and the My Account page → no notice appears.
  3. Confirm a genuinely recoverable subscription still nags: put a subscription on-hold with a payment due → the notice does appear with an "update your payment method" link.
  4. Confirm pending (initial payment not completed) also still shows the notice.
  5. Automated: from plugins/newspack-plugin, run n test-php --group update_payment_noticeOK (10 tests). The suite covers each excluded status (incl. the expired-with-stale-order incident), the on-hold/pending fire paths, the not-needs-payment case, and the allowlist-vs-WCS-status-registry guard.

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?

Cross-publisher impact was reviewed (reader-revenue / third-party-integrations surface): no Newspack repo references this class, the new constant, or the touched filter; the change only ever narrows when the notice shows, so there is no silent-breakage vector. Production diff is one new constant plus the allowlist gate; the rest is tests + test mocks.

Copilot AI review requested due to automatic review settings June 13, 2026 00:23
@jason10lee jason10lee self-assigned this Jun 13, 2026

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

This PR narrows when the WooCommerce “update payment method” notice is generated by gating it to recoverable subscription statuses only, preventing notices on terminal or otherwise non-actionable subscriptions (e.g., expired subscriptions with stale unpaid renewal orders).

Changes:

  • Added an explicit subscription-status allowlist (on-hold, pending) for when the “needs payment” notice is actionable.
  • Added unit tests covering excluded statuses, the reported expired+stale-order incident, and regression guards for on-hold/pending.
  • Extended WooCommerce test mocks to support the new notice code paths (needs_payment(), get_view_order_url(), and wcs_get_subscriptions()).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.

File Description
plugins/newspack-plugin/includes/plugins/woocommerce/class-woocommerce-update-payment-notice.php Adds a recoverable-status allowlist and uses it to gate notice generation.
plugins/newspack-plugin/tests/unit-tests/plugins/woocommerce-update-payment-notice.php Introduces a focused unit test suite for the allowlist/status behavior and incident regression.
plugins/newspack-plugin/tests/mocks/wc-mocks.php Updates WC/WCS mocks to support wcs_get_subscriptions() and subscription methods used by the notice logic.

Comment thread plugins/newspack-plugin/tests/mocks/wc-mocks.php
semantic-release-bot and others added 2 commits June 13, 2026 00:27
…t.1 [skip ci]

# newspack-components [4.4.0-hotfix-nppm-2926-payment-notice-status-allowlist.1](https://github.com/Automattic/newspack-workspace/compare/newspack-components@4.3.0...newspack-components@4.4.0-hotfix-nppm-2926-payment-notice-status-allowlist.1) (2026-06-13)

### Bug Fixes

* **components:** restore className and disabled props on CardSettingsGroup ([226762e](226762e))

### Features

* **reader-activation:** replace RAS auto-enable with manual toggle ([#196](#196)) ([71d2165](71d2165))

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

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

Comment thread packages/components/CHANGELOG.md
Comment thread packages/components/package.json
@jason10lee jason10lee marked this pull request as ready for review June 13, 2026 01:34
@jason10lee jason10lee requested a review from a team as a code owner June 13, 2026 01:34
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.

3 participants