Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Add Short Descriptions for WooCommerce Shipping Methods Below Each Title?

If you need to add short descriptions to specific shipping methods, this snippet is the perfect solution. It’s ideal for scenarios where certain shipping methods require additional explanation or details.

function ts_add_description_field_to_shipping_method( $fields ) {
    $fields['short_description'] = array(
        'title'       => __( 'Short Description', 'woocommerce' ),
        'type'        => 'textarea',
        'description' => __( 'Add a short description for this shipping method.', 'woocommerce' ),
        'default'     => '',
        'desc_tip'    => true,
    );
    return $fields;
}
foreach ( array( 'free_shipping' ) as $method ) {
    add_filter( 'woocommerce_shipping_instance_form_fields_' . $method, 'ts_add_description_field_to_shipping_method' );
}
function ts_add_description_to_shipping_label( $label, $method ) {
    $shipping_zones = WC_Shipping_Zones::get_zones();
    foreach( $shipping_zones as $zone ) {
        foreach( $zone['shipping_methods'] as $instance_id => $shipping_method ) {
            if( $method->get_method_id() === $shipping_method->id && $method->get_instance_id() === (int)$instance_id ) {
                $short_description = $shipping_method->get_option( 'short_description' );
                if( $short_description ) {
                    $label .= '<div class="shipping-method-description">' . esc_html( $short_description ) . '</div>';
                }
            }
        }
    }
    return $label;
}
add_filter( 'woocommerce_cart_shipping_method_full_label', 'ts_add_description_to_shipping_label', 10, 2 );

Output

The code snippet introduces a new field, ‘Short Description,’ to your WooCommerce shipping methods. This field allows you to input descriptions for shipping method through the admin side.

How to Add Short Descriptions for WooCommerce Shipping Methods Below Each Title? - Tyche Softwares

In another scenario, it retrieves and displays the short description on the cart page. This way, customers can view additional information about each shipping method during the checkout process.

How to Add Short Descriptions for WooCommerce Shipping Methods Below Each Title? - Tyche Softwares

Similarly, you can also display a delivery day range based on shipping country on WooCommerce cart page.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
2 Comments
Newest
Oldest
Inline Feedbacks
View all comments
15 days ago

Hello, somehow this code snippet is not working for us.. is it updated to last woocommerce?

Editor
10 days ago
Reply to  Omar

Hi Omar,
We’ve tested the code, and it works fine with the latest versions of WordPress and WooCommerce. Please ensure that you have selected the “Minimum Order Amount” option, as the short description field will only appear when this option is enabled.
You can refer to the screenshot here: https://prnt.sc/Ym451a59va_e. Let us know if you need further assistance!

2
0
Would love your thoughts, please comment.x
()
x