Shopping Cart and Multi-Currency

Converting from one currency to another is possible through Rules. We recommend using only core for this if you want the conversion rate to be input as a static variable. For example, you simply want to say that 1 US dollar is equal to .76 Euros, that would be a fine and relatively easy thing to produce using rules.

Additionally with being able to handle simple conversions, Drupal Commerce core will properly handle mixed currency orders by converting line items to the site's default currency if present on the order or using the currency of the first line item on the order if the default currency isn't represented.

For more complex situations, there is a great contributed module called Commerce Multi-currency that we have highlighted in a recent Commerce Module Tuesday Video (seen below).

Multi-Currency Support in Core

We have lots of use-cases for handling multiple currencies. As stated above, Drupal Commerce supports a small subset of currency support.

Currency
        Settings Screen

Currency Settings

The currency settings screen under Store > Configuration > Currency is where you can enable additional currencies. If you are going to do the "Static Currency Exchange Rate" exercise below, you should enable a few currencies here.

  • Administration
  • Store
  • Configuration
  • Currency Settings

Static Currency Exchange Rate

Converting from one currency to another is possible through Rules. We recommend using only core for this if you want the conversion rate to be input as a static variable. For example, you simply want to say that 1 US dollar is equal to .76 Euros, that would be a fine and relatively easy thing to produce using rules.

Below we work through an entire exercise where we use Rules to create such a scenario as mentioned above.

Let's create a
        static currency conversion for these products!

Original Pricing

The original pricing is shown here for three products. Our goal is to create a rule that affects the prices and changes the currency. Note that you need to enable a few other currencies to make this work.

  • Administration
  • Store
  • View Products
First, Navigate
        to Product pricing rules

Product Pricing Rules

The first step is to click on Store and then "Configuration" and, finally, Product Pricing Rules. That is where the magic all happens when dealing with currency exchange.

  • Administration
  • Store
  • Product Pricing Rules
Click on Add a
        Pricing Rule and Add event

Pricing Rule

We need to click on add a pricing rule. If this is your first time on this screen, maybe navigate around and look at how some of these other rules are setup. If this is your first time dealing with Rules, we highly recommend additional tutorials.

  • Administration
  • Store
  • Product Pricing Rules
  • Click Add a Price
Name your new
        rules so that it makes sense to you.

Name Rule

After you have created a name, click "Add Condition."

  • Administration
  • Store
  • Product Pricing Rules
  • Name Rule
  • Click Add Condition
Write or find the
        following code: commerce-line-item:commerce-unit-price:currency-code

Data Comparison

After clicking "Add Condition…"

You will want to choose "Data Comparison" and then select "commerce-line-item:commerce-unit-price:currency-code" using the object navigator.

  • Administration
  • Store
  • Product Pricing Rules
  • Edit Rule
  • Click Add Condition
  • Choose "Data Comparison"
Choose the
        currency you want to convert. For our example, we are converting US $ to
        something else.

Currency to Filter

Note that we are creating a filter that will only allow US dollars into our actions. Without this filter, all line items would go through this rule.

  • Administration
  • Store
  • Product Pricing Rules
  • Click Add Condition
  • Choose Which Currency to Act On
Select multiply
        to change the unit price.

Convert Numbers

Click "Add Action"

In order to actually create a currency conversion we need to do a little math. This next step is where you add the currency exchange rate.

  • Administration
  • Store
  • Product Pricing Rules
  • Click Add Action
  • Select Multiply
The current
        currency exchange is 0.76 EUR to 1 US Dollars. So we multiply by 0.76

Doing the Exchange

If you had 1 US dollar, how much would that equal in your other currency? It changes, but for our exercise we're going to assume a static number works for us. (Dynamic currency conversion is possible with Commerce Multicurrency).

  • Administration
  • Store
  • Product Pricing Rules
  • Click Add Action
  • Select Multiply
  • Multiply by 0.76
Create a new
        action using the convert to new currency rule.

Convert Currency Symbol

Click Add Action.

Select "Convert the unit price to a different currency" so that we can actually convert the currency from US dollars to a new currency. This exchange is only going to change the currency symbol, it will not actually tweak the numbers.

  • Administration
  • Store
  • Product Pricing Rules
  • Click Add Action
Select the final
        currency destination. For our example, it will be EUR.

Final Currency

We are simply selecting the final currency symbol. You can safely ignore the data selector.

  • Administration
  • Store
  • Product Pricing Rules
  • Click Add Action
  • Select Currency Symbol
Final rule
        screen for Static Currency Exchange Rate.

Final Screen

The final screen for the rule. If yours doesn't look like this, go through the steps above carefully.

  • Administration
  • Store
  • Product Pricing Rules
  • Review Custom Rule
Notice how the
        cart and the product page show the converted price.

Example Cart

We have not modified any of the products prices, but we have successfully converted all of the currency to Euros and exchanged the prices. For example, Product Three is listed as $32.00 US dollars.

Found errors? Think you can improve this documentation? edit this page