Home » WooCommerce: Hide “Shipping to…” Address @ Cart

WooCommerce: Hide “Shipping to…” Address @ Cart

by adminkys

Even when the “shipping calculator” is disabled on the WooCommerce Cart page, a “Shipping to…” string will appear in the cart totals if an address has been previously entered or if geolocation is enabled.

Most WooCommerce store owners, however, wish to remove / hide this text, as it can be confusing for the customer. In this quick tutorial, we’ll study two different workarounds to achieve the same result. Enjoy!

The two alternative snippets below will hide the “Shipping to…” text string that displays below the shipping rates in the WooCommerce Cart totals section

PHP Snippet: Remove “Shipping to…” Text @ WooCommerce Cart Page

There is no WooCommerce hook that can modify the “Shipping to…” string, so we need to find a workaround. One option is to translate the “Shipping to…” string into an empty string.

/**
 * @snippet       Remove "Shipping to..." @ WooCommerce Cart
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 6
 * @donate $9     https://www.tutoraspire.com
 */

add_filter( 'gettext', 'tutoraspire_translate_shippingto', 9999, 3 );
  
function tutoraspire_translate_shippingto( $translated, $untranslated, $domain ) {
if ( ! is_admin() && 'woocommerce' === $domain ) {
switch ( $translated ) {
case 'Shipping to %s.':
$translated = '';
break;
}
}   
return $translated;
}

You can read more about the “gettext” filter and WooCommerce string translation here on Business Bloomer. If this fails, there is another option, which is once again not ideal but it’ll get the job done.

PHP + CSS Snippet: Hide “Shipping to…” String @ WooCommerce Cart

/**
 * @snippet       Hide "Shipping to..." @ WooCommerce Cart
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 6
 * @donate $9     https://www.tutoraspire.com
 */

add_action( 'woocommerce_before_cart', 'tutoraspire_hide_shippingto' );

function tutoraspire_hide_shippingto() {
echo '';
}

You may also like