Skip to content

Conversation

@miguelpeixe
Copy link
Member

@miguelpeixe miguelpeixe commented Dec 1, 2025

All Submissions:

Changes proposed in this Pull Request:

NPPM-2434

Migrated subscriptions don't have an initial order, which is required by Woo Subscription to allow switches. This is checked via the last_order_date_created meta.

This PR implements a strategy to backfill this meta using the scheduled start date value. This should happen on demand while generating the switch cart.

How to test the changes in this Pull Request:

  1. Make sure you have a variable subscription or a grouped product as your primary subscription product (Audience -> Subscriptions)
  2. Manually create a subscription for a reader via wp-admin (WooCommerce -> Subscriptions -> Add Subscription)
  3. Make sure to add a line item for a variant of the primary subscription product
  4. In a new session, visit the site with ?upgrade-subscription=1 and sign in as the reader
  5. Confirm you are not able to continue checkout, as the strategy is only meant for migrated subscriptions
  6. Manually set a _piano_subscription_id or _stripe_subscription_id order meta with any value to the subscription
  7. Visit the ?upgrade-subscription=1 again and confirm you are able to complete the switch

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 ran tests with your changes locally?

@miguelpeixe miguelpeixe marked this pull request as ready for review December 2, 2025 13:42
@miguelpeixe miguelpeixe requested a review from a team as a code owner December 2, 2025 13:42
@miguelpeixe miguelpeixe self-assigned this Dec 2, 2025
@miguelpeixe miguelpeixe added the [Status] Needs Review The issue or pull request needs to be reviewed label Dec 2, 2025
@miguelpeixe miguelpeixe requested a review from Copilot December 2, 2025 13:48
Copy link

Copilot AI left a comment

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 fixes subscription switching for migrated subscriptions that lack an initial order. WooCommerce Subscriptions requires the last_order_date_created meta to allow subscription switches, but subscriptions migrated from Piano or Stripe don't have this value.

Key Changes:

  • Implements a filter hook to detect migrated subscriptions without a last order date
  • Backfills the last_order_date_created meta using the subscription's scheduled start date
  • Performs validation checks to ensure the subscription can be switched before allowing the operation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@github-actions github-actions bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Dec 8, 2025
@miguelpeixe miguelpeixe merged commit 4438b9a into release Dec 8, 2025
9 checks passed
@miguelpeixe miguelpeixe deleted the hotfix/migrated-subscription-switch branch December 8, 2025 19:52
matticbot pushed a commit that referenced this pull request Dec 8, 2025
## [6.27.1](v6.27.0...v6.27.1) (2025-12-08)

### Bug Fixes

* **subscriptions:** migrated subscription switch ([#4335](#4335)) ([4438b9a](4438b9a))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 6.27.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released [Status] Approved The pull request has been reviewed and is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants