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
 * @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

  • WooCommerce: How to Fix the “Cart is Empty” Issue
    For some reason, sometimes you add products to cart but the cart page stays empty (even if you can clearly see the cart widget has products in it for example). But don’t worry – it may just be a simple cache issue (and if you don’t know what cache is that’s no problem either) or […]
  • WooCommerce: “You Only Need $$$ to Get Free Shipping!” @ Cart
    This is a very cool snippet that many of you should use to increase your average order value. Ecommerce customers who are near the “free shipping” threshold will try to add more products to the cart in order to qualify for free shipping. It’s pure psychology. Here’s how we show a simple message on the […]
  • WooCommerce: Cart and Checkout on the Same Page
    This is your ultimate guide – complete with shortcodes, snippets and workarounds – to completely skip the Cart page and have both cart table and checkout form on the same (Checkout) page. But first… why’d you want to do this? Well, if you sell high ticket products (i.e. on average, you sell no more than […]
  • WooCommerce: Disable Payment Method If Product Category @ Cart
    Today we take a look at the WooCommerce Checkout and specifically at how to disable a payment gateway (e.g. PayPal) if a specific product category is in the Cart. There are two tasks to code in this case: (1) based on all the products in the Cart, calculate the list of product categories in the […]
  • WooCommerce: Add Privacy Policy Checkbox @ Checkout
    Here’s a snippet regarding the checkout page. If you’ve been affected by GDPR, you will know you now need users to give you Privacy Policy consent. Or, you might need customer to acknowledge special shipping requirements for example. So, how do we display an additional tick box on the Checkout page (together with the existing […]

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

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 *