2
votes

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.

2

2 Answers

19
votes
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

5
votes

To override woocommerce views, you need to copy the required template files from woocommerce/templates to your theme directory. In this case copy woocommerce/templates/checkout/form_billing.php to your theme folder as woocommerce/checkout/form_billing.php and edit the following code around line 27.

<?php if ( wc_ship_to_billing_address_only() && WC()->cart->needs_shipping() ) : ?>

    <h3><?php _e( 'Billing &amp; Shipping', 'woocommerce' ); ?></h3>

<?php else : ?>

    <h3><?php _e( 'Billing details', 'woocommerce' ); ?></h3>

<?php endif; ?>