Aaron
Aaron

Reputation: 87

How to change WooCommerce text shipping in checkout

I am trying to change a text in the WooCommerce checkout page from Shipping to Delivery from Your Order Section. I tried to open the core files in FTP and tried to change it manually but I couldn't find the text anywhere. Any help on how to change it?

Upvotes: 6

Views: 34024

Answers (4)

ZeroGravity
ZeroGravity

Reputation: 79

I can see this is an older thread but it had the answer I was looking for. I extended the solution from @Rahul S so the one function could translate multiple strings if desired. It it a revision of a function I use for Event Calendar by ModernTribe. Being in the US I used "Shipping and Handling" in place of "Delivery."

add_filter('gettext', 'zgwd1010_woo_translations', 20, 3);
add_filter('ngettext', 'zgwd1010_woo_translations', 20, 3);
function zgwd1010_woo_translations( $translation, $text, $domain ) {

    // Put your custom text here in a key => value pair
    $custom_text = array(
        'Shipping:' => 'Shipping and Handling:',
    );

    if( array_key_exists( $translation, $custom_text ) ) {
        $translation = $custom_text[$translation];
    }
    return $translation;
}

Upvotes: 1

I used the solution by @Rahul S but I added the next code to change specific delivery text on cart and checkout.

I added this code to the function.php on my theme. It work on cart page and checkout page

You can replace ‘put-here-you-domain-i18n’ by you domain, by default it is ‘woocommerce’ by I recommend change it.

The code to add is:

add_filter( 'woocommerce_shipping_package_name' , 'woocommerce_replace_text_shipping_to_delivery', 10, 3);

/**
 * 
 * Function to replace shipping text to delivery text
 * 
 * @param $package_name
 * @param $i
 * @param $package
 *
 * @return string
 */
function woocommerce_replace_text_shipping_to_delivery($package_name, $i, $package){
    return sprintf( _nx( 'Delivery', 'Delivery %d', ( $i + 1 ), 'shipping packages', 'put-here-you-domain-i18n' ), ( $i + 1 ) );
}

I hope help you.

You can see this.

Upvotes: 8

Rahul S
Rahul S

Reputation: 643

Did you tried like this below:

// Add this to your functions.php

add_filter('gettext', 'translate_reply');
add_filter('ngettext', 'translate_reply');

function translate_reply($translated) {
$translated = str_ireplace('Shipping', 'Delivery', $translated);
return $translated;
}

Please see this link too: http://businessbloomer.com/woocommerce-edit-translate-shipping-handling-cart-checkout-page/ for more details

Upvotes: 15

Lucasaid
Lucasaid

Reputation: 59

If you copy the files you need to edit from wp-content/plugins/woocommerce/templates to wp-content/themes/*your_theme*/woocommerce. That way you can override the code without touching the plugins code.

You will find the code you need to change will be under wp-content/themes/*your_theme*/woocommerce/checkout, although if you want to change all instances of the word Shipping you will need to change more of the templates.

List of files that contain Shipping are

woocommerce/cart/cart-shipping.php

woocommerce/cart/cart-totals.php

woocommerce/cart/shipping-calculator.php

woocommerce/checkout/form-billing.php

woocommerce/checkout/form-login.php

woocommerce/emails/email-addresses.php

woocommerce/emails/plain/email-addresses.php

woocommerce/myaccount/form-edit-address.php

woocommerce/myaccount/my-address.php

woocommerce/order/order-details.php

There is probably more so you'll have to do a search in the other template files.

Upvotes: 4

Related Questions