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.
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.
Similarly, you can also display a delivery day range based on shipping country on WooCommerce cart page.
Hello, somehow this code snippet is not working for us.. is it updated to last woocommerce?
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!
Hi,
I have the same problem. The snippet works as far as adding the short description when defining the shipping method, but the description doesn’t appear at checkout.
Is the snippet supposed to go under the functions.php of the theme? That’s where I’ve put it.
Thanks!
Hi KNude,
Yes, the snippet should be placed in your theme’s functions.php file. The code has been tested and it works fine in the updated version of WooCommerce 9.7.1, displaying the description on both the cart and checkout pages. If it’s not appearing, try switching to a default theme (like Storefront) and disabling other plugins. If the issue persists, please share any other customizations you’ve made related to shipping for better troubleshooting.