WooCommerce: edit or translate “Shipping and Handling” on the Cart & Checkout page

A client, clearly from a European English-speaking country (not many, uh?), wanted to change the cart page when it says “Shipping” or “Shipping and Handling” in the totals table. The same string appears on the checkout page. As it’s only 1 string, my favourite method is by implementing a very simple PHP function, that needs to be placed in your functions.php file.

Our WooCommerce Issue: how to translate/edit “Shipping and Handling” on the cart page?

Editing the Cart page in WooCommerce
Editing the Cart page in WooCommerce

PHP Snippet: translate “Shipping and Handling” in WooCommerce


// Add this to your functions.php

add_filter('gettext', 'translate_reply');
add_filter('ngettext', 'translate_reply');
 
function translate_reply($translated) {
$translated = str_ireplace('Shipping and Handling', 'Postage & Packaging', $translated);
return $translated;
}

Where to add this code?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such delicate files - if you need more guidance, please take a look at my free WooCommerce Customization video tutorial.

Does this snippet still work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free videos, tutorials and tips!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP
  • woocommerce-customize-shop-page-PHP
  • woocommerce-advanced-customization
  • how-to-edit-woocommerce-cart
  • woocommerce-customize-checkout-page-PHP
  • woocommerce-email-customization
  • woocommerce-conditional-logic

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

22 thoughts on “WooCommerce: edit or translate “Shipping and Handling” on the Cart & Checkout page

  1. great snippet works great. Thank u very much

  2. Hi !

    Thanks for a great article !

    The code only replaces one instance of “shipping” to “delivery” on my page (the Address) section but not the instance in the total section. I’ve tried experimenting with changing other words (e.g. Total) and this works. Any idea what’s stopping the translation for shipping ?

    Many thanks in advance for any advice – much appreciated ๐Ÿ™‚

    1. Hey Richard, thanks for your comment! You might need a second call or maybe that’s coming from your theme or specific plugin. Sorry but I can’t offer free support here in the blog comments ๐Ÿ™‚

  3. hi. my site is multilingual (English as main language & Bahasa Indonesia). if i use this code, is the translated version going to show only when visitor switch to Bahasa Indonesia? (i want it to be so)
    thanks

    1. Hey Sandra, thanks so much for your comment! No, this solution I think applies to all languages – if your site is multilingual, instead, you should have a function to edit such string in your multilingual plugin. Do you use WPML or similar?

  4. Hi Rodolfo!

    I attended your class last month and signed up to attend the one next week- I’m so excited!

    I am interested in renaming the “Calculate Shipping” button (located under Cart Totals Table) to “Calculate Taxes” (since this functionality calculates both shipping & taxes) so I wanted to know if you had any idea how to rename it? I did some research and there appears to be a Shipping.php file but I know if a new version of Woocommerce comes out it would get overridden. Any ideas? Also, is it possible to add the “Calculate” button on the Checkout page as well?

    Thanks,

    April

    1. April – awesome! I’m looking forward to next week’s event as well ๐Ÿ™‚

      In regard to the string translation question, check this out: https://businessbloomer.com/translate-single-string-woocommerce-wordpress/. It should help you with that.

      In relation to the calculate button, the checkout calculates shipping already – not sure why you would need it there again? Maybe explain that a little better and I’ll get back to you with an answer ๐Ÿ™‚

      Cheers!

    2. Hi Rodolfo,

      Great, thanks! I will check out the thread.

      So, the reason why I was interested in adding the ‘Calculate Shipping’ to the Checkout Page as well, is just in case the user doesn’t calculate the shipping on the Cart page and wants to do it on Checkout. I do think it’s redundant but I just wanted the user to have the option for both pages ๐Ÿ™‚

      Thanks,

      April

    3. No problem ๐Ÿ™‚

      Re: shipping calculator I don’t honestly think that’s good for UX. On the checkout, people can select shipping methods and “calculate” shipping in that way – it’d be redundant in my opinion. Of course there is a way to add it there as well (find the PHP that is generating the calculator and try copy/paste that on the checkout via a hook) – good luck!

    4. You have a good point! Thanks for the insight. Have a great day ๐Ÿ™‚

    5. No problem at all ๐Ÿ™‚ Talk soon!

  5. Great in theory, and I used it to change from “Shipping” to “Shipping and Handling”, but I was frustrated to find that it changes it everywhere. It even says “Shipping & Handling Address” instead of “Shipping Address” on the invoice. Is there a way to just change it just on the cart totals and invoice totals?

    1. Thanks for your feedback! Good point – of course you can trigger the function only on the Cart page for example by using:

      if (is_cart()) {
      // run function
      }

      In this way the snippet will only be called on the Cart page. Hope this helps!

  6. Hello,
    Great, thank you for that! ๐Ÿ™‚
    Can i remove text with that function?
    Best regards!

    1. Anze, thanks for your feedback! Of course – just enter ” (2 single quotes) in the second place and the string will be translated into an empty one! Rodolfo

  7. Fatal error: Call to undefined function add_filter() in /home/u627751393/public_html/wp-includes/functions.php on line 10

    1. Thanks Anon for your feedback. This code works with every version of Woocommerce so you probably forgot an apostrophe or a parenthesis. Can you check this please?

  8. Hi

    Can this be used to translate more than one string?

    1. Yes Tom, of course. Use an array:

      // Add this to your functions.php
      add_filter('gettext', 'translate_enhu');
      add_filter('ngettext', 'translate_enhu');
      function translate_enhu($translated) {
      $before = array ("word1", "word2");
      $after = array ("newword1", "newword2");
      $translated = str_ireplace($before, $after, $translated);
      return $translated;
      }
      
  9. Hi… and if I wanted to translate that string in 5 languages … how can I do?
    Thanks ๐Ÿ™‚

    1. Mik thanks for your message! If you want to translate this in 5 languages you will need to use a plugin such as WPML or Codestyling Localization (a free plugin that used to be on the WordPress repository but for some reason I can’t find at the moment). Hope this helps!

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.