Updated Woocommerce shipping text
Changing WooCommerce Text
Updated Woocommerce shipping text

Updated WooCommerce Checkout Text

Recently

I had a client e-mail me about an issue with her WooCommerce checkout page. She was contacted by a customer whose billing address was in Canada, with a shipping address here in the United States. The customer found the second part of the checkout page where she could input her actual shipping address just fine, but right above this section was a checkbox (checked by default), which read, “Shipping Address Same As Billing Address“.

When the customer unchecked the box, the “ship to a different address” form disappeared. It re-appeared when checked again. In my mind, and apparently the customer and client’s minds as well, that functionality was completely backwards.

I decided the functionality (displaying/hiding the form upon checking the checkbox) was good as it was, but the text needed to be changed to something more intuitive, like, “Check Box To Ship To A Different Address“.

I decided the best way to go about this was to place a PHP function I found elsewhere online in my client’s Child Theme, that would allow us to easily change any default WooCommerce text we want now and in the future. Here’s the code:

add_filter('gettext', 'custom_strings_translation', 20, 3);

function custom_strings_translation( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'Shipping address same as billing address' :
            $translated_text = __( 'Check Box to Ship to a Different Address', '__x__' );
        break;
    }
    return $translated_text;
}

Simply place the text you want changed as the case in the switch function, and place the text you’d rather have in the next line, and then you’re done!