WPML Setup with WP EasyCart

WPML is a popular plugin that is used to convert a WordPress website into multiple languages. More information can be found at WPML’s website

Steps For Integration

1. Ensure language files exist for the WP EasyCart by visiting your WP EasyCart -> Settings -> Language Editor. Read below if you need to add a language file to fit your requirements.

2. Add Languages as needed: You can add or delete language packs to ensure you are matching which languages you want to have with WPML.

3. Working with a language pack: Just select which language you would like active on your site by default and you can edit other languages by selecting them. Whichever you select will be default though.

4. Ensure the language codes match: For each, scroll down to the bottom of the page and check the language code. Make sure the language codes match, for example, WPML uses ES for Spanish and by default the EasyCart displays SP, resave after change each to match what WPML uses.

5. Be sure settings in WPML are correct. There are a lot of variables and settings in WPML, and this guide recommends you use basic installation of plugin. We always ensure that you have the URL linking for WPML set to use URL linking variable method. If you utilize other methods, EasyCart may not recognize those.

6. Add a “Store”, “Account”, and “Cart” page for each WPML language. You can click the + plus sign for each language in WPML you are allowing. In this example, you can see we have our three pages (store, cart, account) in default english. But we can edit the french and greek pages for each store, cart, account.

7. For all language pages, you should use (example is for a Spanish translation, change to match correct language code): [ec_store language=”ES”], [ec_cart language=”ES”], and [ec_account language=”ES”]

8. View your Pages: You should be able to view your store, account, or cart page and switch languages using WPML flags or dropdowns. Basic store data like add to cart buttons and phrases should all adjust based on that language pack found in our settings -> language editor.

In this example, we have English, French, and Greek flags from WPML to switch language, and you notice we are on french and see the french title of the product, french model number, and french add to cart button.

9. Translate Your Products: Throughout the product setups, you can force a translation of any text by entering a translation of each. For example, if you want a product title to be different for English and German, enter [EN]English Title[/EN][DE]German Title[/DE]. The store will translate based on the WPML language selected.

Language Switcher Fix in Store

If you would like to be able to switch languages within a product, you should add the following code to your theme’s functions.php file.

add_filter('icl_ls_languages', 'wpml_ls_filter');add_filter('icl_ls_languages', 'wpml_ls_filter');function wpml_ls_filter($languages) { if( isset( $_GET['model_number'] ) ){ global $sitepress; foreach( $languages as $lang_code => $language ){ $languages[$lang_code]['url'] = $languages[$lang_code]['url'] . '&model_number='.$_GET['model_number']; } } return $languages;} }

How to Add a New Language File and create your own!

Note: Once you have added a language file and accessed the advanced language page, you cannot make changes to the language file directly! In order to prevent changes to language from being overwritten during an upgrade, language data is stored in your database once imported. The following instructions therefore only apply to those who need to add a new language to the system!

  1. Copy any of the existing text files, located in wp-content/plugins/wp-easycart/inc/language/, and rename to something that makes sense.
  2. Open the file and make changes as needed. Keep in mind, json formatting is very specific and any mistake in formatting will result in an error. Please run the file through something like https://jsonlint.com/ before uploading to your server to prevent errors.
  3. Go to your EasyCart Admin -> Store Setup -> Advanced Language to complete the insertion of a new language
  4. If you have made errors in the translation, you must make changes through the advanced language page, NOT THE TXT FILE UPLOADED. If you have a translation that you would like to add to the default EasyCart plugin, please email us with your file and we will add it to the core.