This is a note on how to implement the Drupal commerce_multicurrency module.
This recipe is for a site with two currencies, with manual currency conversion: we are going to manually add our prices in both currencies rather than using the European Central Bank conversion provided by commerce_multicurrency.
Users to the site may select which currency they wish to pay with, like this.
In my case, the default currency is GBP (British Pounds Sterling) and the additional currency is EUR (Euro).
Start with Drupal Commerce and its dependencies downloaded.
drush dl commerce
drush dl entity
drush dl rules
drush dl addressfield
drush dl views
drush dl ctools
I have enabled all of the commerce modules, and the dependencies as prompted.
Download and enable commerce_multicurrency.
admin/commerce/config/currency/settings
Enable the required currencies.
I enabled EUR and GBP, removed USD.
I set GBP as default.
In my case I want to have manual, not automatic, currency conversion.
Commerce Multicurrency provides a Currency Handling tab.
admin/commerce/config/currency/handling
I enabled a dedicated price field for Euro only.
(In my case the default price will be in British Pounds – I don’t need to enable a field to hold GBP prices – the default price field is enough).
Go to: admin/commerce/products/types
manage display so that the foreign currency field is hidden on the teaser and
Set up some products with product displays
Store > Products > Add
In Drupal Commerce, products do not display on the site automatically.
Add a content type called Product display. Add a Product Reference field to the content type.
On the manage display tab, hide the foreign currency field: we only want one field for price to be shown in the display. If you wish, add the Product reference field to the teaser – this will provide the Add to Cart button.
For each product, create a Product display node.
Enable shopping cart and currency selector blocks
I added Currency Selector and Shopping Cart to Sidebar first.
Create the Rule that will make the Currency Selector work
The Currency Selector block will set the site user’s currency preference.
In order to change the prices displayed when the user changes currency, we need to set up a Rule.
Import the following Rule:
admin/config/workflow/rules/reaction/import
{ "commerce_multicurrency_set_currency_price_eur" : {
"LABEL" : "Set the currency price to EUR",
"PLUGIN" : "reaction rule",
"WEIGHT" : "-9",
"REQUIRES" : [ "rules", "commerce_line_item", "commerce_product_reference" ],
"ON" : [ "commerce_product_calculate_sell_price" ],
"IF" : [
{ "data_is" : { "data" : [ "site:commerce-currency" ], "value" : "EUR" } },
{ "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "commerce_product" } },
{ "entity_has_field" : {
"entity" : [ "commerce-line-item:commerce-product" ],
"field" : "commerce_price_eur"
}
},
{ "NOT data_is_empty" : { "data" : [ "commerce-line-item:commerce-product:commerce-price-eur" ] } }
],
"DO" : [
{ "commerce_line_item_unit_price_amount" : {
"commerce_line_item" : [ "commerce-line-item" ],
"amount" : [ "commerce-line-item:commerce-product:commerce-price-eur:amount" ],
"component_name" : "base_price",
"round_mode" : "1"
}
},
{ "commerce_line_item_unit_price_currency_code" : {
"commerce_line_item" : [ "commerce_line_item" ],
"currency_code" : "EUR"
}
}
]
}
}
Cache pages for anonymous users
If your site caches pages for anonymous users (as it should: admin/config/development/performance) then you will experience a problem with the Select currency drop-down for anonymous users: you change it, but nothing happens – the currency remains the same.
I noticed the problem when I noticed the currency switcher not working for anonymous, but working fine when logged in.
The issue and a solution to it are discussed here: http://drupal.org/node/1516128
















