Disable in-dashboard subscription cancellation in WooCommerce

Dec 13, 2022 #woocommerce

The WooCommerce Subscriptions plugin offers a self-service dashboard for customers to manage their subscriptions. By default this includes the option to manually cancel their subscription.

Some business models require that the customer speak to an account manager before a subscription can be cancelled. For such a use case the subscription cancel button can be removed from the customer dashboard.

/**
 * Removes the "cancel" action from the account subscription actions.
 */
add_filter( 'wcs_view_subscription_actions', function( $actions ){
    unset($actions['cancel']);
    return $actions;
}, 10, 1 );

Additionally, a custom message can be added to the customer dashboard explaining the required steps for cancelling a subscription. The below snippet is an example of adding a message after the subscription actions in the WooCommerce dashboard.

/**
 * See templates/myaccount/subscription-details.php
 */
add_action( 'woocommerce_subscription_after_actions', function() {
    echo "
      <p>
      To revise or cancel your subscription, call 555-555-5555 or
      send an email to support@woocommerce.test at least 3 business
      days (Monday-Friday) before your next membership renewal date. 
      Refunds are not granted following auto-renewal dates.
      </p>";
});
By Kyle B. Johnson
Founding Member

Kyle Johnson is a contributor to WordPress core, WP-CLI, and Gutenberg. He speaks at WordCamps and Open Source conferences. As a collector of hobbies he is also a musician, furniture maker, amateur lock pick, avid reader, and wannabe book author.

Site Builders Guild - Tools and community for people who build websites.