1 min read

Change WooCommerce Cart to Basket

Change WooCommerce Cart to Basket

Update December 2017

Well, I was searching for this and my own page appeared in the results. It looks like I’m doing the same things I was doing in 2014!

The method outlined in the original post is the same, so it’s still worth reading, however the code has changed a bit. I’ve also added some extra code to amend the ‘Add to’ button. Add this code to your functions.php:

https://gist.github.com/raisonon/c7d315cc996976994b0d4d19febd9fe9

Most UK shops are more familiar with the word basket and want to have all the references to cart removed.

Fortunately the latest version of WooCommerce makes this considerably easier than it used to be. Previously you would have to change the .po and .mo localization files. However with the latest version of WooCommerce we can state the store is British in our wp-config.php file and then this will automatically apply the localization changes.

1) Open wp-config and make sure the following is added:

define (‘WPLANG’, ‘en_GB’);

2) If you want to just change specific elements but don’t want to change everything to British then head over to webdevdoor.com who have outlined how this can be done with specific filters:

http://www.webdevdoor.com/ecommerce/change-woocommerce-cart-text-sitewide/

3) Finally, the following code can be used to translate any items added using internationalization functions.

https://gist.github.com/raisonon/e95aed633f909a29d7ee

This method can be used to amend any text that has been added using a localization function. Have a look at the original code and determine what the $domain is and then add it as I have in the above Gist. You can also add WordPress conditional statements such as is_single() or is_front_page() if you want to translate based on conditional factors. Skys the limit!

More reading here: http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext

http://speakinginbytes.com/2013/10/gettext-filter-wordpress/

Apologies to all the Brits for spelling localisation with the Z above! Thought it best to keep it as per the WordPress documentation.