Changing Cart to Basket in Woocommerce (Creating Languages files for Woocommerce)

In this post I’m going to explain how to change all instances of cart to basket in Woocommerce.

Update (23/12/2016)

There is a way to hack it, if its just Cart to Basket that you want to change (or just a couple of strings), you could add something like below to the themes functions.php file:

function gb_change_cart_string($translated_text, $text, $domain) {

$translated_text = str_replace(“cart”, “basket”, $translated_text);

$translated_text = str_replace(“Cart”, “Basket”, $translated_text);

return $translated_text;
}

add_filter(‘gettext’, ‘gb_change_cart_string’, 100, 3);

 

The slightly longer way to change strings in Woocommerce (such as cart to basket).

The way todo this is too create/edit a language file.

1. woocommerce how to change cart text to basket. We need to get the strings source definition file ( the file that has the definitions of all the strings that can be converted into other languages). To find this goto
[wordpress]/wp-content/plugins/woocommerce/i18n/languages

you see 2 files:

woocommerce.pot
woocommerce-admin.pot

These contain the strings used in the front end and the admin section respectively. For our example we’ll just change things in the front end so the file we need is: woocommerce.pot (copy this somewhere, you can work on it).

2. From the woocommerce.pot file , we will create a new language file that will contain our ‘Basket’ translations (using Poedit ). Open the file in poedit and select create a new translation from pot file

using poedit for woocommerce language translation

 

 

2. Select the language you want the translation file in ( in this case English UK )

woocommerce language file

3. go through the file (using find) adding a translation where you find instances of cart. e.g. ‘Add to Cart’ , create a translation ‘Add to Basket’

creating a UK language file for for Woocommerce

4. When your done save the file as woocommerce-en_GB.po . This will create 2 language files for woocommerce (woocommerce-en_GB.po and woocommerce-en_GB.mo )

5. Now go to your website and in wp-content, create a folder called languages (if one doesn’t exist already)

6. In this folder create another folder called woocommerce

so you have [wordpress]/wp-content/languages/woocommerce

7. Its in this folder that we need to put the woo language files (created in step 4) that will override the default woocommerce language file (if one exists for UK english). So drop woocommerce-en_GB.po and woocommerce-en_GB.mo in the WordPress directory: [wordpress]/wp-content/languages/woocommerce

Thats it we’re done.

8. look at your website in a browser and see how all the places that Cart appeared have changed to Basket.

The language files will remain and not be overwritten when we update Woocommerce (we don’t want to lose our translations everytime we update so this is good). I hope you’ve found this guide on: woocommerce how to change cart text to basket useful. If you need help with a Woocommerce website get in touch my rates are very reasonable.

 

 

18 thoughts on “Changing Cart to Basket in Woocommerce (Creating Languages files for Woocommerce)”

  1. Hey Louie

    Thank you for explaining how to change Cart to Basket in Woocommerce.

    your instructions are very clear and easy to follow….

    however ive done every thing you suggested but nothing has changed…

    any ideas why. it would really be appreciated.

    we are based in the UK too. so need the word basket site wide..

    I am building a site with Dynamik Website Builder on the Genesis framework if that helps you in anyway..

    cheers Jason

    Reply
    • hi Jason,

      Sorry to hear thats not working for you, its difficult to say without trouble shooting it.

      But there is a way to hack it, if its just Cart to Basket that you want to change, you could add something like below to the themes functions.php file:

      function gb_change_cart_string($translated_text, $text, $domain) {

      $translated_text = str_replace(“cart”, “basket”, $translated_text);

      $translated_text = str_replace(“Cart”, “Basket”, $translated_text);

      return $translated_text;
      }

      add_filter(‘gettext’, ‘gb_change_cart_string’, 100, 3);

      Reply
  2. Hi Louie.. Thanks for getting back to me.

    I added your snippet you suggested to my custom functions box but it didn’t change anything.. maybe I’ll start again and try to Create the Languages files again.

    unless there is anything else you can suggest?

    cheers

    Reply
    • hi Jason,

      That’s about all i can think of at the moment, I would need to have a look at your site to diagnose further.

      If you need any paid help I’m usually available , with a little bit of notice 🙂

      Reply
      • Hi Louie,

        we have been having the same problem as Jason as we are UK based too and need our site to say “basket” instead of “cart” (and possibly “voucher” instead of “coupon” in the future). I see you say you can help for a price. We launch next wk so need help pretty quick. Can you help? and if so, what do you charge? And would you be able to help with any future problems too?

        I look forward to hearing from you.

        Thanks

        Alice

        Reply
        • hi Alice,

          sorry to hear your having problems, unfortunately I’m really busy at the moment. My prices and some packages I offer are on my homepage.

          Would you mind if I added you to my email list (I send useful tips in this).

          check out my blog post on Increasing sales here: http://green-box.co.uk/ecommerce-tips-help-increase-sales/

          sorry I can’t help this time, very busy time of the year with Black Friday and Christmas etc ….

          Reply
    • Hi there

      I had this problem too. the solution was to change the theme. Unfortunately not all themes are built equally especially when it comes to translation

      regards
      Linda

      Reply
  3. Hi Louie (sorry in advance for my poor english),

    I downloaded .po and .mo files in purpose to make my website entirely in french. I put the .mo and .po files in the right folder but it doesn’t react at all. I don’t know what to do, do you have an idea why it doesn’t work?

    Reply
  4. Thanks for this. It was driving me insane trying to figure out how to change ‘add to cart’ without overwriting all the foreign translations…

    Reply
  5. Thanks, the functions.php soluton works in part but not everywhere. For example, after adding a product to the cart I am still getting message: “2 × “Sweet & Spiced Tomato” have been added to your cart.”

    Also just to warn others, copying and pasting your code will cause errors due to the formatting of the double and single quotation characters, “ ” need to be changed to ” and ‘ ’ to ‘.

    Reply
    • good spot with the quotes Glauco, for the instance where it still says Cart it might be hard coded into the theme

      Reply
  6. HI,

    the text replace function didnt work for me either, as I want cart to be changed to basket. It is not coded into the theme. Looking at many of the other replies to this post I guess this method is simply just not an “across the board” solution. Thanks for going to the effort to try to post a solution, but not working in all cases.

    Reply
    • hey Peter,

      sorry to hear its not working for you. possibly it only works in some versions of Woocommerce. I’d like to revisit this post in the future to see if I can make it more comprehensive.

      What theme and version of Woocommerce are you using ? And are you overriding any of the theme templates ?

      Reply
  7. I tried the replace function too, didn’t work for WooCommerce Version 3.1.2 .

    For some reason it’s ‘Cart Totals’ ‘Update cart’ on the cart page that won’t translate even though they are translated fine in the translation files. Same with ‘Items’ in the menu once you add something to the cart.

    Reply
  8. It didn’t work for me at first, but then I realised I needed to switch on English UK under dashboard>settings>general
    It was set to English US before.
    Hope that helps someone

    Reply

Leave a Comment