Drupal 7 Localization and the Commerce module

This post explains how to configure some Drupal Commerce module package functionality for multiple countries and languages. This information was originally going to be part of my Drupal 7 Multilingual Sites book but I ran out of room!

Ecommerce

If you need ecommerce functionality for Drupal 7, your choices are Ubercart and Commerce (which is a complete rewrite of Ubercart). It shouldn't matter what your hosting provider is as long as you can install Drupal 7 in the normal way. For my multilingual demo site, I chose the Commerce package since it's new and shiny. I've used Ubercart in the past and it is totally fine. If you want to use Ubercart, there are lots of tutorials as well as a Drupal 6 Ubercart book available by George Papadongonas and Yiannis Doxaras.

The main things to consider for ecommerce localization are product content, currencies, taxation, and shipping. For products, just translate content as needed such as names and descriptions. For currency support, you might allow different currencies depending on your payment processing company. Taxation and shipping charges typically vary depending on the shipping location, so you'll need configure the rates accordingly.

Commerce Product entity type

The Commerce package creates a custom Commerce Product entity type which is used to define a product. To *display* a product, you must create a product display content type with a reference field for one or more products. Ryan Szrama has a great post on configuring product display content types for your Commerce products.

Drupal 7 Multilingual Sites explains how to configure content types for multilingual support using the node translation (via the core Content translation module) and the field translation (via the Entity translation module) methods. You will need to configure your product display content type using one of those methods. And, if there are product fields to localize as well (in addition to product display fields), you also need to configure field translation for the Commerce Product entity type using the following steps:

Configure entity type

  1. Enable the Entity translation module.
  2. Go to Configuration | Regional and language | Entity translation.
  3. Select the entity type, e.g. Commerce Product.
  4. Click Save configuration.
  5. Edit the entity, e.g. for a Book product entity, go to Store | Products | Product types | Book | Edit.
  6. Select Enabled via Field translation checkbox.
  7. Click Save button.

Configure fields

Note that steps 2 to 4 below will change once this Entity translation module patch gets committed: drupal.org/node/1279372. Translations will be enabled/disabled on the main edit page (bottom of form), rather than on the Field settings page.

  1. Edit entity field, e.g. for a Book product entity, go to Store | Products | Product types | Book | Manage Fields and click edit for a field.
  2. Click Field settings tab.
  3. Select Users may translate this field checkbox.
  4. Click Save field settings button.
  5. Repeat for all fields to localize.

Translate content

  1. Edit entity content, e.g. for a Book product entity, go to Store | Products | List and click edit for a particular Book product.
  2. Choose language and save.
  3. Edit entity content again and click Translate tab.
  4. Click add translation link for a language.
  5. Translate content and click Save translation.
  6. Repeat for all languages.

Currencies, taxes and shipping

If you have international customers, you'll likely need to configure currencies, taxes, and shipping for them. Let's walk through this for the Commerce package. Start with installing these modules:

Currencies

By default, the US Dollar currency is enabled, but it's easy to include other currencies. Navigate to Store | Configuration | Currency settings, click on Enabled currencies, choose your currencies, and click Save configuration.



This is the same place you can change your store's default currency, if desired. Once the currencies are enabled, you can use them when adding products, shipping rates, etc.



For example, I used Euros for a book price and now it shows up looking very European!



To extend the Commerce currency support, try out the Commerce Multicurrency module. It lets you define exchange rates, synchronize rates with the European Central Bank, and provides hooks to add custom exchange rates. Nice!

What currency the actual payment process uses will depend on your payment methods and what they support. For example, you can set up Commerce Paypal or Commerce Authorize.Net modules to use the currencies you have on your site. That way a customer can buy a product in Euros, US Dollars, etc. For more payment options, check out the Drupal Commerce payment FAQs.

Taxes

To configure taxes, navigate to Store | Configuration | Taxes and click Add a tax rate. You'll see a form to add the tax information such as the rate and type of tax (e.g. Sales Tax, VAT tax). Once you've added all your tax rates, it will look something like this:



Now click configure component to setup the tax rate rules. This part is a little trickier. Click add condition and then choose Commerce Order: Order address component comparison.

You'll be shown a somewhat daunting form. Fill out the form as follows:

  • Order: Data selector => commerce-line-item:order
  • Address: Value => Shipping information: Address
  • Address Component: Value => Country
  • VALUE: Value => put in the country code, e.g. de

Then click the Save button and you'll see an overview page with your configuration.



Just click Save changes and then repeat the process for each country that needs taxes applied.

Shipping

For shipping rates, we'll assume we want a flat rate for each country. Here's the process:

  1. Go to Store | Configuration | Shipping.
  2. Click Add a flat rate service link.
  3. Fill in the Title (e.g. German Shipping) and Base rate (e.g. 10 EUR).
  4. Click Save flat rate button.
  5. Click configure component link.
  6. Click Add condition link.
  7. Choose Commerce Order: Order address component comparison option.
  8. Fill in form with the same values as with taxes except the Order: Data selector field should be set to commerce-order.
  9. Click Save button.
  10. Click Save changes button to see the overview.


  11. Repeat for each flat rate.

Have fun with your multilingual Drupal Commerce site!

If you have a question, feedback, or find an error, please leave a comment below. Thanks!

AttachmentSize
8185_05_12.png2.51 KB
8185_05_13.png2.4 KB
8185_05_14.png5.46 KB
8185_05_15.png6.54 KB
chapter5_ecommerce_currency_book_price.png6.6 KB
chapter5_ecommerce_currency_book_price_view.png6.72 KB
chapter5_ecommerce_currency_euro.png5.04 KB
chapter5_ecommerce_shipping_condition.png8.97 KB
chapter5_ecommerce_taxes_condition.png7.66 KB

Comments

Putting your article to test.

Putting your article to test. Just learning about drupal - non-programmer.
I could not get the product body to translate.
using kickstart v7-2.2
1. enable entity module.
2, enable commerce product
2. content type, product display, published enable with translation.
I could get the product title to work.
but not the body (product description). Do you mind giving some more hand holding tips.

Contact me

Hi... just seeing this. I get a lot of spam even with mollom configured. Use the contact form and contact me if you still are trying to figure this out after all these months! Also, we are doing a multilingual training at BADCamp. It's full but maybe you could get on the wait list if you are going.

Thanks Kristen for this

Thanks Kristen for this excellent writeup, your writing style is very easy to follow for non-English readers.

I am very impressed by Drupal Commerce. Great flexibility through lots of specialized contrib modules and leveraging Drupal's awesome translation mechanism it will beat any shop system out there including Magento. While easier to use, config and extend.

Tom
@webtomme

Great!

Glad it's easy read... that is definitely one of my *main* goals when writing :)

Comment

Educational Article! At last somebody that really knows what they are talking about and can also produce readable content for us that read it. Definitely looking forward to your next offering.

Post new comment - ALL COMMENTS ARE MODERATED - SPAM WILL BE DELETED!

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.