WooCommerce: Add Shipping Rate Description @ Cart & Checkout Page

Each payment method on the WooCommerce Checkout page comes with a description right below the label. What if we could achieve something similar for the shipping rates, so that we can explain to the customer the difference between each method?

This question came up today in our private Slack channel for Woo developers, and we were able to write a quick snippet that does the trick. Here’s the complete code – enjoy!

Here’s a brand new description for a specific shipping method ID in the WooCommerce Checkout page. Code below!

PHP Snippet: Display Shipping Method Description in the WooCommerce Checkout Page

This code is a WooCommerce snippet that adds a custom description after a specific shipping method on the checkout page. Here’s a breakdown of what each part of the code does:

  • add_action(): This function adds an action hook that triggers the bbloomer_shipping_rate_description function after the shipping rate is displayed on the checkout page. The hook used here is woocommerce_after_shipping_rate.
  • bbloomer_shipping_rate_description() function: This function defines the custom behavior for displaying the shipping rate description. It takes the shipping method object as a parameter.
  • Conditional Check: Inside the function, there’s a conditional check to determine if the shipping method being displayed has a specific ID (free_shipping:6). If it does, a custom HTML message is echoed out to explain the benefits of choosing this shipping rate.
  • HTML Output: The HTML output is a simple paragraph tag containing the desired message. This message could contain any information deemed relevant for the specific shipping method identified by its ID.

Overall, this code allows you to customize the display of shipping method descriptions on the WooCommerce checkout page, specifically targeting a shipping method with the ID free_shipping:6.

For more info on how to find your shipping rate IDs, check the “How to Find Shipping Class ID” paragraph here: https://businessbloomer.com/woocommerce-disable-free-shipping-if-cart-has-shipping-class

/**
 * @snippet       Shipping Method Description @ WooCommerce Checkout
 * @tutorial      Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WooCommerce 8
 * @community     Join https://businessbloomer.com/club/
 */

add_action( 'woocommerce_after_shipping_rate', 'bbloomer_shipping_rate_description' );
 
function bbloomer_shipping_rate_description( $method ) {
	if ( $method->id === 'free_shipping:6' ) {
		echo '<p>Some HTML in here where you can explain the benefits of choosing this shipping rate</p>';
	}
}

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

12 thoughts on “WooCommerce: Add Shipping Rate Description @ Cart & Checkout Page

  1. Works perfectly. Thank you. As always, excellent work 😉

  2. Hi,
    Thanks, could you please tell me how you made these shipping charges look in a line?

    In my theme, it shows as:

    Shipping on the left table and then on the right shows options to select the shipping method.

    Could you help me with this? I want to show the charges like this. First shipping and then on left label of the shipping option and on the right the charges of that shipping option.

    Thanks in advance!

    1. It’s just the theme, hence just some custom HTML/CSS, nothing special

      1. Hi, thank you for your reply. Could you please tell me which theme it is?

  3. I was so pleasantly surprised by how seamlessly this integrated. Thanks a bunch!

  4. Thanks! Works great. Does this works for multiple shipping ID’s? If so, could you provide an example?

    1. Menno, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  5. Perfect. Thank you men

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *