WooCommerce: Add Hyperlink to Shipping Method Label @ Cart & Checkout

Let’s say you want to help customers understand your shipping rates and benefits right on the WooCommerce Cart and Checkout pages, by adding a link to each shipping option (e.g. “View shipping FAQ“).

As you can see from the first and second screenshot below, if you enter any HTML within the WooCommerce shipping zone -> shipping method settings, this will be stripped out, and HTML tags such as hyperlinks won’t work.

So, how can we add a clickable text link to each shipping method, given that we can’t use the WooCommerce settings? Well, as usual, a quick PHP snippet can help us with that. Enjoy!

If we enter any HTML in the shipping method settings…
…WooCommerce strips the HTML on the frontend, so it’s not possible to add hyperlinks for example.
Let’s change that! With a simple PHP snippet, you can add any HTML at the beginning or end of the single shipping rate label, such as a hyperlink.

PHP Snippet: Add Text Hyperlink to Shipping Methods @ WooCommerce Cart & Checkout

/**
 * @snippet       Add HTML to Shipping Rate Label @ WooCommerce Cart & Checkout
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WooCommerce 9
 * @community     https://businessbloomer.com/club/
 */

add_filter( 'woocommerce_cart_shipping_method_full_label', 'bbloomer_shipping_method_suffix', 9999, 2 );

function bbloomer_shipping_method_suffix( $label, $method ) {
   return $label . ' (<a href="">shipping FAQ</a>)';
}

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

4 thoughts on “WooCommerce: Add Hyperlink to Shipping Method Label @ Cart & Checkout

  1. Hi, I was excited to see your elegant solution. It doesn’t seem to work, but maybe I’m just not understanding how to format/syntax the label in order to make the hyperlink work

    WordPress (6.3.1)
    WooCommerce version: 8.0.3

    1. Hey Richard, did you use my exact code or did you edit it?

      1. Hello. This does work, but adds to ALL shipping methods. Do you have a way to specify a particular method only? Thanks Rodolfo! (enjoyed your AMA btw!)

        1. Thank you Paul!

          The filter also comes with a second parameter, which I’ve now added to the snippet, and in this way you have access to the “$method->id” – so you can run the function only if “$method->id” is “cod” or “bacs” or whatever payment gateway ID

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 *