WPML Integration and Multi-Currency Support

Version 1.3 of WooCommerce User Role Pricing adds full support for WPML/WCML, including multi-currency support and optimizations.  If you are not using the Multi-Currency feature, there is nothing extra you need to configure in the settings. However, even if you don’t use Multi-Currency, you should still read over the sections below to ensure that your custom prices get properly configured for every translation of your products, and that custom text strings are also translated for each language.

Requirements

Full multi-currency support, including manual currency prices, is only possible with the new filter hooks added in WCML version 3.8, so you need to be running at least that version to use Multi-Currency with custom prices.  Version 1.3 of User Role Pricing was created and tested using versions 3.4.1 of WPML Multilingual CMS, 3.8.2 of WooCommerce Multilingual, 2.3.9 of WPML String Translation, 2.2.1 of WPML Translation Management, and 2.1.22 of WPML Media.

Settings

When WPML/WCML is active on your site, there will be a new tab “WPML Integration” on the WooCommerce>User Role Pricing page.

If you have Multi-Currency enabled, there will be a check box “Save min/max currency prices”. This is enabled by default and will save the min & max variation custom prices for each active currency in the post meta table for the Variable parent product. If you have a lot of Variable products displayed in your shop, this may help speed up the page load time as the displayed price range will be shown by getting those saved min/max values from the database, as opposed to looping through every child variation of the Variable product, calculating the custom price for each, and determining the min and max. If you disable this feature, custom price min/max ranges for Variable products will always be calculated by looping through all variations and calculating the price for each.

After Multi-Currency has been enabled and you have added the additional currencies you want to use, you should run the Sync Variable Products function again so that default values can be set for every currency. This should be done whether or not you are using saved min/max currency prices. After that, Variable products will automatically sync (individually) any time that you edit them.

Product Translations

You shouldn’t have to change anything for User Role Pricing to work with product translations.  The product meta fields for each custom price you create are set to be automatically copied to translations.

However, you need to make sure to create and translate the products the correct way for this to work. I strongly suggest that you use the WPML recommended way of using their own “WPML Translation Editor” to translate products, instead of using the “Native WooCommerce product editing screen” to edit your translations.  In short, you should always duplicate your products after you create the original product in the main site language and edit the text translations using the product WPML Translation editor.  Alternately, you can go directly to the Translation Editor and create translations of existing products there.  Using one of those two ways, the prices and all other product fields set to “copy” will always be copied to all translations, and you won’t have to worry about prices getting out of sync between translations. If you ever need to change prices, you use the regular WooCommerce product editor, while your admin area is set to the site default language, and then just change the prices on only that version of the product. When you hit update, those prices will be copied to any other language versions.

To summarize, if you are creating a new product, make sure you are creating it in the default language of your site. After you enter all the info and publish the product, you have two ways to create the translations. Right after the product is published, you will see some new options in the Language meta box above the Publish box.  You can either check the boxes for the “Duplicate” option, which will simply duplicate the product with the default language text to each translated language (you can edit the text for the other translations later), or you can click on the + signs to create the translation and open the Translation Editor for that product to edit the text right then. The third option is to do nothing, which will then leave that product in only the default language, and you can come back to it later to create the translations.

Unless you have a very strong reason to, it is NOT recommended to use the Native WooCommerce product editing screen and then create an independent product copy for each language (you can do that if you are editing the product in a non-default language and you set the “This is a translation of” select box to “none”).  If you do that and save the product, then that particular language product becomes its own separate product, with its own independent price fields (the fields will become unlocked after you publish it). At that point, you will need to remember that your different language versions of that product are no longer synchronized, so if you change the prices of one language, you need to remember to change the prices for the other language versions as well.

Multi-Currency Prices

If you are using at least version 3.8 of the WooCommerce Multilingual plugin, then your custom prices will work fully with Multi-Currency, with either automatic conversions, or manual setting of prices for each currency.

Automatic Conversions

If you already have custom prices entered for your products in the default language, and you enable multi-currency mode and add some additional currencies, then by default, all prices, including custom prices, will be automatically converted to the other currencies based on the currency exchange rates you set when you set up the additional currencies.  There is nothing additional you need to do for this to work. However, if you have Variable products, you should run the Sync Variable Products function again so that the mix/max variation prices can be calculated for each variable product for the shop price range display (they will be calculated with the exchange rates you set). Alternately, you can disable the saving of min/max variation prices for each currency (as described above), and those price ranges will be re-calculated on every page load.

Manual Conversions

If you don’t want to use automatic currency conversion, you can manually enter prices for each product or variation in each currency. WCML adds a couple of radio buttons on the product/variation editor pages where you can set if prices are calculated automatically, or entered manually.  This is set on a per product, or per variation, level, so you can create manual prices for just some products or variations, but still use automatic conversion for others. If you set it to manual, you will then be presented with a set of price fields for each additional currency, including all of your custom price fields.  For each currency, you can manually enter your custom prices, or leave them blank. If you leave them blank for one or more currencies, then the custom prices for each blank currency will be automatically calculated based on the exchange rate you entered and the specific custom price you set for the default currency.  Thus, “manual” currency prices only apply if you actually enter a custom price for that specific currency, otherwise it will still be calculated automatically. In other words, it’s not possible to not have a custom price for only some currencies… it’s all or nothing.

The only exception/quirk to the manual prices is that if you leave a custom price blank for the default currency, you can still manually enter custom prices for one or more other currencies, in which case you will only see custom prices (and only be able to add-to-cart) when viewing in one of the currencies where you did enter a price. However, if you have the User Role Pricing plugin set to hide products without a price, then that product will never show up in the shop loop no matter what currency you are currently set to, since the query that filter products without prices is done on the main (default currency) custom price meta field.  I’m not sure why you would ever want to set up any products that way, but it is possible.

Translation of custom Messages and Text

As of version 1.3, User Role Pricing has two custom text strings that can be defined by admin on the General section page of the User Role Pricing settings page. These will need translation for other languages.  These custom strings are registered through the plugin so that they can be translated easily from the “String Translation” page of WPML.  Note that if you leave some of those fields blank in the User Role Pricing settings, those fields will NOT show up on the String Translation.

The easiest way to find and translate those custom strings from the WPML String Translation page is to select “WooCommerce User Role Pricing” from the “Select strings within domain:” select box and hit the search button. You can then edit each string translation.