strangerstudios / pmpro-woocommerce

Connect Paid Memberships Pro with WooCommerce and WooCommerce Subscriptions to sell membership products and offer members-only product discounts.
https://www.paidmembershipspro.com/add-ons/pmpro-woocommerce/
46 stars 32 forks source link

Membership is not canceled in PMPro when a Woo subscription upgrades to a higher membership, then cancels their subscription #162

Closed MaryOJob closed 5 months ago

MaryOJob commented 2 years ago

Describe the bug If a member upgrades to a level with a higher subscription membership from a lower one (for example, the current membership level is $40 and the member upgrades to a level that costs $50), both the initial level and upgraded level are applied in PMPro correctly.

However, if they go ahead to cancel their subscription, their account goes into pending cancelation and then canceled. Once their membership is canceled, the level in PMPro remains on the level they canceled on. And they still have access to content that should be restricted to that level.

To Reproduce Steps to reproduce the behavior:

  1. Activate and setup 'PMPro WooCommerce, PMPro, WooCommerce Subscriptions'
  2. Allow members to be able to upgrade or download in WooCommerce
  3. Check out for a level with a lower amount, afterwards, upgrade to a level with a higher amount
  4. Check that both initial and upgraded levels are applied correctly in PMPro
  5. Cancel your subscription in WooCommerce
  6. Go to the WP Edit User profile page once Woo subscription status reads canceled
  7. See issue

Screenshots

Screen Shot 2022-01-31 at 11 29 23 Screen Shot 2022-01-31 at 11 29 09

Screen Shot 2022-01-31 at 12 00 07

Expected behavior When the WooCommerce subscription is completely canceled, the membership status in PMPro should be set to None and level canceled as well.

Isolating the problem (mark completed items with an [x]):

WordPress Environment

``` `WordPress Version 5.9` `Twenty Twenty Theme Version 1.9` `WooCommerce Subscriptions Version 3.1.6` `WooCommerce Version 6.1.1` `PMPro Version 2.7.2` `PMPro WooCommerce 1.7.3` `PHP Version 7.4.27` ```
MaryOJob commented 2 years ago

For Moderators Only Ticket Tag: #391063

andrewlimaza commented 1 year ago

I've retested this with the latest dev branch and it works as intended. Levels are removed when subscriptions are cancelled.

My test had 2 subscriptions linked to different levels, I then cancelled one sub at a time and the relevant level was removed. I will leave this issue open for a bit to monitor this issue further for more edge cases.

piotrkunicki commented 1 year ago

@andrewlimaza did you test it with the upgrade? This bug occurs only after subscription upgrade (not 2 different subscriptions) (https://woocommerce.com/document/subscriptions/switching-guide/)

andrewlimaza commented 1 year ago

@piotrkunicki I was able to replicate when using a variation subscription product (upgrading and downgrading the subscription itself). We will continue to investigate this.

andrewlimaza commented 1 year ago

Steps to replicate this issue

  1. Create a variable subscription product, with various pricing subscriptions.
  2. Link a membership level to this product.
  3. Purchase the cheapest subscription (any variation would be able to replicate this issue).
  4. Navigate to the WooCommerce account page > subscriptions.
  5. View the subscription
  6. Select to upgrade the subscription (it should redirect you back to this product page).
  7. Choose a different variation price (from step 3) and complete checkout.
  8. Cancel the subscription to see the error. The member's level stays active.

If on local environments, be sure to process/approve the order in WooCommerce between each step if it's not marked as "completed".

stan-saluda commented 1 year ago

Hi! Any update on that? It's really a troublesome error as every month or so we need to manually look for customers who are exploiting this bug and getting a free membership.

dwanjuki commented 1 year ago

I observed that cancelling a variable subscription product order does not cancel the linked membership ever, even when not upgrading.

To replicate:

  1. Create a variable subscription product.
  2. Link a membership to this product.
  3. Purchase any variation of this subscription.
  4. Navigate to the WooCommerce > Subscriptions.
  5. Cancel the subscription you just purchased.
  6. Observe that the account still has a membership level.

My environment: WP 6.2.2 PMPro 2.11 PMPro WooCommerce Add On 1.7.7 WooCommerce 7.7.2 WooCommerce Subscriptions 5.0.0

Mods: Ticket #498680

andrewlimaza commented 5 months ago

@dwanjuki adding a note here, the latest dev branch now supports Variable Subscription Products and cancellations. Here is the merged PR - https://github.com/strangerstudios/pmpro-woocommerce/pull/199

andrewlimaza commented 5 months ago

I can confirm that this is now fixed with the dev branch! I believe the issue was cancelling with variable subscription products didn't honor this product type and it now does. I will be closing this one out and mark it as resolved.