Level already has an end date. Set to false so we really cancel.
This is not always wanted, at all.
Example 1: Sometimes people are cancelling one more time (after the first time disabling the auto-renewal).
You would say "let's have a gist to remove the cancel button if already set an end date". That's ok.
Example 2: Sometimes people are double clicking the cancellation link, very fast, on the cancel confirmation page.
first time is setting and end date
second time (yeah, because we don't really have concurrency) it really cancel.
You would say "we can fix javascript to avoid double clicks". That's ok too.
Describe the solution you'd like
Both examples 1 and 2 deserve their own solution. But when you just don't want to permit a complete cancellation until expiration, there are many ways to break it. Can we just try to think differently?
Instead of trying to fix it from every side, I would hack the exact line which is causing this.
I would replace this:
if ( empty( $check_level ) || ( ! empty( $check_level->enddate ) && '0000-00-00 00:00:00' !== $check_level->enddate ) ) {
// Level already has an end date. Set to false so we really cancel.
$pmpro_next_payment_timestamp = false;
}
with
if ( empty( $check_level ) ) {
// No order found, immediate cancellation.
$pmpro_next_payment_timestamp = false;
} elseif ( ! empty( $check_level->enddate ) && '0000-00-00 00:00:00' !== $check_level->enddate ) {
if ( apply_filters( 'pmproconpd_permit_complete_cancellation', true ) ) {
// Level already has an end date. Set to false so we really cancel.
$pmpro_next_payment_timestamp = false;
} else {
// Leave it untouched. Don't want to cancel.
// Returning the cancel level instead of 0. This should be enough to keep their membership.
return $cancel_level;
}
}
Snippet to disable complete cancellation
// 1. Add the snippet to remove the cancel button if already have an end date.
// ...
// 2. Add the snippet (js) to avoid fast double click the cancel button on cancel confirmation page
// ...
// 3. Then add this filter to disable complete cancellation completely:
add_filter( 'pmproconpd_permit_complete_cancellation', '__return_false' );
The current state of the art is to completely cancel if level already has an end date
https://github.com/strangerstudios/pmpro-cancel-on-next-payment-date/blob/dev/pmpro-cancel-on-next-payment-date.php#L82-L83
This is not always wanted, at all.
Example 1: Sometimes people are cancelling one more time (after the first time disabling the auto-renewal).
You would say "let's have a gist to remove the cancel button if already set an end date". That's ok.
Example 2: Sometimes people are double clicking the cancellation link, very fast, on the cancel confirmation page.
You would say "we can fix javascript to avoid double clicks". That's ok too.
Describe the solution you'd like
Both examples 1 and 2 deserve their own solution. But when you just don't want to permit a complete cancellation until expiration, there are many ways to break it. Can we just try to think differently?
Instead of trying to fix it from every side, I would hack the exact line which is causing this.
I would replace this:
with
Snippet to disable complete cancellation