Menu Close

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

default

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        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 8
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_filter( 'woocommerce_cart_shipping_method_full_label', 'bbloomer_shipping_method_suffix' );

function bbloomer_shipping_method_suffix( $label ) {
   return $label . ' (<a href="">shipping FAQ</a>)';
}
View Source
Posted in WooCommerce Tips