Search code examples
phpwordpresswoocommercetranslationcheckout

Change "Billing Details" text to "Shipping Details" on WooCommerce checkout page


I currently have a bit of code in my child theme's functions.php file which is supposed to change "Billing Details" to say "Shipping Details" on my WooCommerce checkout page.

However, when I updated to WooCommerce 3.0, the code snippet stopped working. Below is the code I was using.

function wc_billing_field_strings( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'Billing Details' :
            $translated_text = __( 'Shipping Details', 'woocommerce' );
            break;
    }
    return $translated_text;
}

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

I would really like a code snippet that works with WooCommerce 3.0+.


Solution

  • function wc_billing_field_strings( $translated_text, $text, $domain ) {
        switch ( $translated_text ) {
            case 'Billing details' :
                $translated_text = __( 'Billing Info', 'woocommerce' );
                break;
        }
        return $translated_text;
    }
    add_filter( 'gettext', 'wc_billing_field_strings', 20, 3 );
    

    Tested OK with WooCommerce 3.0.6