Customizing the My Subscriptions Page

WooCommerce Subscriptions adds a My Subscriptions section to the My Account page to help customers manage their subscriptions more easily. If you want to customize the My Subscriptions section, you can modify the template associated with it. You can update the template the same way you override core WooCommerce templates.

Look for the template is called my-subscriptions.php . It is located under the /myaccount/ folder. To override it in your theme, copy the /templates/myaccount/my-subscriptions.php file found in the WooSubscriptions plugin folder to your theme using the location: /woocommerce/myaccount/my-subscriptions.php. From there, you can follow the process outlined here to modify it.

    Adding a confirmation message on the My Account page

    ↑ Back to top

    By default when a customer clicks the suspend, cancel or renew button on their My Account page, the action processes immediately without any confirmation from the customer.

    There are two ways you can achieve this:

    • Mini-Plugin – Using this free mini-plugin that you can download and install. This will add a confirmation pop-up box so that customers can confirm they would like to proceed with the cancellation, suspension, or renewal of their subscription.
    • JavaScript – You can use a JavaScript confirmation dialogue by following these instructions:
    1. Copy the /woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/templates/myaccount/subscription-details.php template from the plugin folder into your theme’s folder at the location /woocommerce/myaccount/subscription-details.php. (Learn more about overriding WooCommerce templates).
    2. Find the line used to display the link button for each action. Its HTML is shown below and it is contained within a table with the class subscription_details.
    3. Replace the link text with the new link text included below.

    The original link will look like this:

    <a href="<?php echo esc_url( $action['url'] ); ?>" class="button <?php echo sanitize_html_class( $key ) ?>"><?php echo esc_html( $action['name'] ); ?></a>
    

    To display a confirmation dialogue, change the link markup to this:

    					<?php if(in_array($key, array('cancel', 'suspend'))) : ?>
    
    					<a href="<?php echo esc_url( $action['url'] ); ?>" class="button <?php echo sanitize_html_class( $key ) ?>" onclick="return confirm('<?php printf( __( 'Are you sure you want to %s this subscription?', 'woocommerce-subscriptions' ), esc_html( $action['name'] ) ); ?>');"><?php echo esc_html( $action['name'] ); ?></a>
    
    
    					<?php else: ?>
    
    					<a href="<?php echo esc_url( $action['url'] ); ?>" class="button <?php echo sanitize_html_class( $key ) ?>"><?php echo esc_html( $action['name'] ); ?></a>
    
    
    					<?php endif; ?>
    Cancel Subscription Confirmation Dialogue
    Cancel Subscription Confirmation Dialogue
    Use of your personal data
    We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.