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
- Enable the Entity translation module.
- Go to Configuration | Regional and language | Entity translation.
- Select the entity type, e.g. Commerce Product.
- Click Save configuration.
- Edit the entity, e.g. for a Book product entity, go to Store | Products | Product types | Book | Edit.
- Select Enabled via Field translation checkbox.
- 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.
- 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.
- Click Field settings tab.
- Select Users may translate this field checkbox.
- Click Save field settings button.
- Repeat for all fields to localize.
Translate content
- Edit entity content, e.g. for a Book product entity, go to Store | Products | List and click edit for a particular Book product.
- Choose language and save.
- Edit entity content again and click Translate tab.
- Click add translation link for a language.
- Translate content and click Save translation.
- 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:
- Commerce Flat Rate
- Commerce Shipping and Shipping UI
- Commerce Tax and Tax UI (in Commerce package)
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:
- Go to Store | Configuration | Shipping.
- Click Add a flat rate service link.
- Fill in the Title (e.g. German Shipping) and Base rate (e.g. 10 EUR).
- Click Save flat rate button.
- Click configure component link.
- Click Add condition link.
- Choose Commerce Order: Order address component comparison option.
- Fill in form with the same values as with taxes except the Order: Data selector field should be set to commerce-order.
- Click Save button.
- Click Save changes button to see the overview.
- 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!
Attachment | Size |
---|---|
8185_05_12.png | 2.51 KB |
8185_05_13.png | 2.4 KB |
8185_05_14.png | 5.46 KB |
8185_05_15.png | 6.54 KB |
chapter5_ecommerce_currency_book_price.png | 6.6 KB |
chapter5_ecommerce_currency_book_price_view.png | 6.72 KB |
chapter5_ecommerce_currency_euro.png | 5.04 KB |
chapter5_ecommerce_shipping_condition.png | 8.97 KB |
chapter5_ecommerce_taxes_condition.png | 7.66 KB |
- kristen's blog
- 173969 reads
This is a featured content block that has been configured to show blog nodes with terms SEO or Drupal SEO by the author kristen. It shows random list of 20 results in the block and 30 results on the more page.
- Drupal Pathauto Module
- Basic SEO Top 10
- Free Google Keyword Research Tool
- Drupal Pathauto URL Aliases Settings
- Fix Duplicate Content with Global Redirect Module
- Drupal SEO Reviews
- Free SEO Tools
- Drupal Has Multiple h1 Tags
- Kristen
- 503 HTTP Status Code when Site Down
- HTML Validation: Free HTML Validator Tools
- Drupal Node Teaser SEO
- Drupal SEO Modules
- BADCamp Drupal SEO Presentation 2009
- Drupal Meta Tags (nodewords) Module for SEO
- Drupal Nofollow Link Sculpting
- Make Drupal SEO Friendly
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.