This article will show you how to add a cancellation confirmation button to WooCommerce Subscriptions. WooCommerce Subscriptions is a great way to offer subscription based products on a WordPress website, but if a user goes to cancel their subscription, this happens instantly. When cancelling, many users don't understand that this is an irreversible action, and after the pending cancellation., their data is removed from the website. What that means is that they will need to resubscribe to a subscription if they ever want to receive it in the future. If prices change, they won't be grandfathered into the previous subscriptions price.
To clarify, the standard behavior of cancellation in WooCommerce Subscriptions is this. The customer navigates to the my account dashboard, goes to the individual subscription, clicks cancel, and it is immediately cancelled.
This behavior isn't great, especially because there is a suspend feature that places the subscription on hold. This is very similar to canceling a subscription, except when you suspend it, all data remains in place, and the customer can reactivate the subscription at any time.
In many situations, suspending a subscription is great for both the consumer and the business. The business retains all the information on the customer, and the customer is incentivized to come back to the subscription when they need it or can afford it again.
To push customers to suspend their subscription instead of canceling, it makes sense to add a confirmation popup to the WooCommerce Subscription cancel button. Ascentia Lee, when somebody clicks on the cancel button under WooCommerce Subscriptions, instead of immediately canceling the subscription, it displays a popup prompting them to suspend it instead. While the customer can then go ahead and click OK, still canceling the subscription, in many cases they abort the cancellation, and decide to suspend.
Installing this code is very easy, you can add it to your functions.php file, by using code snippets, where by using Advanced Scripts (our review). Advanced Scripts is our recommended method of installing any and all code snippets on a WordPress website as it makes it very easy to do so. Simply copy and paste this into a new Advanced Scripts entry, select PHP, insert it into the WP-head and test out the behavior on the front end of your website.
After installation, when clicking cancel, a confirmation message will pop up, prompting a user to suspend their WooCommerce Subscription instead of cancel it.