Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure active status for memberships tied to active subs #3050

Merged
merged 1 commit into from
Apr 9, 2024

Conversation

dkoo
Copy link
Contributor

@dkoo dkoo commented Apr 8, 2024

All Submissions:

Changes proposed in this Pull Request:

Fixes what seems to be a bug in the WC Memberships plugin. When the same user has both a previously expired/cancelled subscription and a newer active one, the "Expires" date from the expired/cancelled subscription forces the user's membership to a expired status, even though the newer subscription is still active and should grant membership.

How to test the changes in this Pull Request:

  1. On a site with WC Memberships + Subscriptions, create a Membership Plan and tie it to "Product Purchase" + "Subscription length". Set it to restrict some content such as a post category.
Screenshot 2024-04-08 at 4 47 10 PM
  1. As a reader, purchase a subscription to the product selected in step 1. Observe that a membership is created in WooCommerce > Memberships with "active" status.
  2. In WP admin, manually cancel the subscription. Observe that the membership is updated to "expired" status with an "Expires" date matching when you changed the subscription status.
  3. As the same reader in step 2, purchase another subscription of the same product.
  4. While on relase, in WP admin, confim that the membership gets reassociated with the new active subscription. But observe that it gets set to "active" status and then immediately to "expired" status again due to the persistence of the "Expires" date from the first cancelled subscription.
Screenshot 2024-04-08 at 4 50 53 PM
  1. Also observe that as a reader, you're not able to access any content restricted by the Membership Plan.
  2. Check out this branch and refresh the membership in WP admin. Confirm that the "Expires" date is cleared out and that the status has been reset to "active".
  3. As the reader, confirm that you once again have access to restricted content due to the active subscription.

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?

@dkoo dkoo added the [Status] Needs Review The issue or pull request needs to be reviewed label Apr 8, 2024
@dkoo dkoo self-assigned this Apr 8, 2024
@dkoo dkoo requested a review from a team as a code owner April 8, 2024 22:54
Copy link
Member

@adekbadek adekbadek left a comment

Choose a reason for hiding this comment

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

Observe that the membership is updated to "expired" status with an "Expires" date matching when you changed the subscription status.

I can't reproduce the issue on the release branch. After cancelling the subscription, the membership enters "Pending Cancellation" state (my test product is a monthly subscription, so the membership is active for another month still), not "Expired".

@dkoo
Copy link
Contributor Author

dkoo commented Apr 9, 2024

I can't reproduce the issue on the release branch. After cancelling the subscription, the membership enters "Pending Cancellation" state (my test product is a monthly subscription, so the membership is active for another month still), not "Expired".

What about if you force it into a cancelled status immediately via WP admin?

Copy link
Contributor

@claudiulodro claudiulodro left a comment

Choose a reason for hiding this comment

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

Works well in my testing. I like how defensively this is coded too!

@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 Apr 9, 2024
@dkoo dkoo merged commit b74a06d into release Apr 9, 2024
10 checks passed
@dkoo dkoo deleted the hotfix/ensure-active-memberships branch April 9, 2024 22:24
matticbot pushed a commit that referenced this pull request Apr 9, 2024
## [3.6.1](v3.6.0...v3.6.1) (2024-04-09)

### Bug Fixes

* ensure active status for memberships tied to active subs ([#3050](#3050)) ([b74a06d](b74a06d))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 3.6.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

dkoo added a commit that referenced this pull request Apr 11, 2024
dkoo added a commit that referenced this pull request Apr 11, 2024
dkoo added a commit that referenced this pull request Apr 11, 2024
dkoo added a commit that referenced this pull request Apr 11, 2024
matticbot pushed a commit that referenced this pull request Apr 11, 2024
## [3.6.5](v3.6.4...v3.6.5) (2024-04-11)

### Bug Fixes

* revert [#3050](#3050) due to performance issues ([#3059](#3059)) ([1d45d9e](1d45d9e))
matticbot pushed a commit that referenced this pull request Apr 11, 2024
# [3.7.0-alpha.1](v3.6.7...v3.7.0-alpha.1) (2024-04-11)

### Bug Fixes

* prevent multiple inputs from resetting in autocompletetokenfield component ([#3023](#3023)) ([7f30d79](7f30d79))
* **reader-reg-block:** respect newsletter subscription checkbox state ([#3024](#3024)) ([02728d3](02728d3))
* revert [#3050](#3050) due to performance issues ([#3059](#3059)) ([a986c17](a986c17))

### Features

* support for MC tags as subscription lists ([#3035](#3035)) ([c363630](c363630))
matticbot pushed a commit that referenced this pull request Apr 24, 2024
# [3.7.0](v3.6.13...v3.7.0) (2024-04-24)

### Bug Fixes

* prevent multiple inputs from resetting in autocompletetokenfield component ([#3023](#3023)) ([7f30d79](7f30d79))
* **reader-reg-block:** respect newsletter subscription checkbox state ([#3024](#3024)) ([02728d3](02728d3))
* revert [#3050](#3050) due to performance issues ([#3059](#3059)) ([a986c17](a986c17))

### Features

* support for MC tags as subscription lists ([#3035](#3035)) ([c363630](c363630))
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