WooCommerce websites offering subscription products often use the WooCommerce Subscriptions plugin to manage customer subscription details. By default, the Subscriptions page in the customer’s account section displays a table with basic information, such as the subscription number, status, and the next payment date as shown below.
However, there may be cases where adding more details (like the product name associated with each subscription) can improve user experience.This customization allows you to modify WooCommerce’s default subscription table to include an additional “Product Name” column, thus providing more informative and personalized details in the subscription table.
Note: This customization requires the WooCommerce Subscriptions plugin to be activated in order to function properly.
add_action( 'woocommerce_account_subscriptions_endpoint', 'ts_replace_subscription_table_with_custom', 1 ); function ts_replace_subscription_table_with_custom() { // Start output buffering to capture WooCommerce Subscriptions output ob_start(); } add_action( 'woocommerce_account_subscriptions_endpoint', 'ts_render_custom_subscription_table', 100 ); function ts_render_custom_subscription_table() { // Get the captured output $content = ob_get_clean(); // Check if the default table output is present and replace it if ( strpos( $content, 'woocommerce-orders-table--subscriptions' ) !== false ) { // Get subscriptions for the current user $subscriptions = wcs_get_users_subscriptions(); if ( empty( $subscriptions ) ) { echo '<p class="no_subscriptions">' . esc_html__( 'You have no active subscriptions.', 'woocommerce-subscriptions' ) . '</p>'; return; } // Output the custom table instead of the default table ?> <table class="woocommerce-orders-table woocommerce-orders-table--subscriptions"> <thead> <tr> <th><?php esc_html_e( 'Subscription', 'woocommerce-subscriptions' ); ?></th> <th><?php esc_html_e( 'Status', 'woocommerce-subscriptions' ); ?></th> <th><?php esc_html_e( 'Next Payment', 'woocommerce-subscriptions' ); ?></th> <th><?php esc_html_e( 'Total', 'woocommerce-subscriptions' ); ?></th> <th><?php esc_html_e( 'Product Name', 'woocommerce-subscriptions' ); ?></th> <!-- New Column --> <th><?php esc_html_e( 'Actions', 'woocommerce-subscriptions' ); ?></th> </tr> </thead> <tbody> <?php foreach ( $subscriptions as $subscription ) : ?> <tr> <td> <a href="<?php echo esc_url( $subscription->get_view_order_url() ); ?>"> <?php echo esc_html( '#' . $subscription->get_order_number() ); ?> </a> </td> <td><?php echo esc_html( wcs_get_subscription_status_name( $subscription->get_status() ) ); ?></td> <td><?php echo esc_html( $subscription->get_date_to_display( 'next_payment' ) ); ?></td> <td><?php echo wp_kses_post( $subscription->get_formatted_order_total() ); ?></td> <td> <?php $items = $subscription->get_items(); $product_names = []; foreach ( $items as $item ) { $product = $item->get_product(); if ( $product ) { $product_names[] = $product->get_name(); } } echo esc_html( implode( ', ', $product_names ) ?: __( 'No Product', 'woocommerce-subscriptions' ) ); ?> </td> <td> <a href="<?php echo esc_url( $subscription->get_view_order_url() ); ?>" class="button"><?php esc_html_e( 'View', 'woocommerce-subscriptions' ); ?></a> </td> </tr> <?php endforeach; ?> </tbody> </table> <?php } else { echo $content; } }
Output
Once the code is implemented, customers visiting the subscriptions page will now see the modified WooCommerce subscription table that includes an additional column, providing more detailed subscription information, such as the product name.
If you want to show additional details like delivery dates and time slots for subscription products on specific spots, you can use the Order Delivery Date (ORDD) Plugin for WooCommerce. This plugin is integrated with WooCommerce Subscriptions, allowing you to display these logistics details wherever needed, such as on the order details page or directly on product pages.