strangerstudios / pmpro-cancel-on-next-payment-date

Change membership cancellation in Paid Memberships Pro to set expiration for next payment date instead of cancelling immediately.
https://www.paidmembershipspro.com/add-ons/cancel-on-next-payment-date
8 stars 8 forks source link

NOT WORKING? #41

Closed fanopolis closed 1 year ago

fanopolis commented 2 years ago

I have this plugin installed but it seems it's not working?

I have PMPro version 2.7.2.

When users cancel, their membership is canceled immediately instead of it being canceled at the end of the billing period.

So basically this plugin is not working. Can someone confirm?

thanks

mircobabini commented 2 years ago

The plugin is working. Can you please add some more details?

Thanks.

fanopolis commented 2 years ago

Thanks for responding so fast Mirco.

I'm looking at one case specifically. They canceled from the site, not the gateway. It was a stripe payment. What is strange is that I received two admin notification emails about the cancellation, at the same time. One has the correct date, but the other one has today's date.

Thank you!

mircobabini commented 2 years ago

Thanks for the insights.

Well, this is a known bug actually. I faced it too and already digged into it.

When you click the "cancel" button it takes some time for the page to reload and actually cancel the membership. Sometimes the users click the cancel button once again. The result is a double cancellation request.

They are almost concurrent but since there's no real concurrency here, they are subsequent.

  1. The first one will cancel the membership by setting an expiration date ad expected.
  2. The second one, sees the membership already cancelled with an expiration date set. Then, it completely cancel the membership. This is the exact line of code: https://github.com/strangerstudios/pmpro-cancel-on-next-payment-date/blob/dev/pmpro-cancel-on-next-payment-date.php#L81-L83

This is clearly an unwanted behaviour and the solution is made of two separate steps.

The first thing you want to do is to avoid double clicks on the cancel button. This can be done via javascript by disabling the button as soon as clicked. I can provide a snippet for this.

Secondly we may want to add something, maybe a filter, to avoid complete cancellation. I mean, with this "filter" set as true, I would expect to keep the membership until expiration date, no way to completely cancel it. This might also mean we don't want to show the "cancel" button anymore when the renewal is already cancelled.

This is something we internally discussed a few times. It's also reported in this draft PR: https://github.com/strangerstudios/pmpro-cancel-on-next-payment-date/pull/37

Let's keep @ideadude in the loop to see if we can come up with a complete solution here.

fanopolis commented 2 years ago

Understood. Thank you very much.

Can you link me to that snippet, please?

michaelbeil commented 2 years ago

@fanopolis This is a gist to avoid complete cancellation (https://github.com/strangerstudios/pmpro-cancel-on-next-payment-date/issues/16#issuecomment-1061839803).

fanopolis commented 2 years ago

Thank you @michaelbeil ! Do I add it to functions.php or where?

michaelbeil commented 2 years ago

You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method. If you need further help, you can open a new ticket and we would be happy to provide you with assistance for this Add On in our member support area.

kathleenfrank commented 1 year ago

I am having this same issue. @mircobabini What is the snippet to avoid double clicks on the cancel button?

michaelbeil commented 1 year ago

@kathleenfrank This is the gist to avoid complete cancellation (mentioned here). If you need further help, you can open a ticket in our member support area.

ideadude commented 1 year ago

Duplicate of https://github.com/strangerstudios/pmpro-cancel-on-next-payment-date/issues/42