How to change woocommerce text shipping in checkou

2019-02-15 09:40发布

问题:

Hi i am trying to Change a text in woo commerce checkout page from 'Shipping' to 'Delivery' from Your OrderSection. i tried open the core files from the FTP to try to change it manually but i couldn't find that text anywhere. Any help Where can i get and change it?

Thanks

回答1:

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



回答2:

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.



回答3:

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.