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!
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.
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.
- 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:
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.
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.
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!
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.