Developers

Translations

Most ecommerce endpoints support translating some values to all your site's languages. When you append ?include=translations to the API request URL, the translations object is also included for all objects that can be translated. This includes all values in all languages.

Reading values

By default, the root values are defaulted to the store's default_language, but you can override them via the X-Language header or ?language_code= URL parameter which changes the root level values to the given language translation, if possible.

For example, if your site's default language is "en" and your product's name is translated like so:

"translations": {
  "name": {
    "en": "Product (en)", "et": "Product (et)"
  }
}
GET /admin/api/ecommerce/v1/products/1
{
  ...,
  "name": "Product (en)",
  ...
}
GET /admin/api/ecommerce/v1/products/1?language_code=et
{
  ...,
  "name": "Product (et)",
  ...
}

Updating values

If you omit the translations key from the request body, all root level values are used for updating the object for the default language. If you include the translations key, all values inside that object are used instead.

A simple example: given your site's default language is "en" and your product's name is translated like so:

"translations": {
  "name": {
    "en": "Product (en)", "et": "Product (et)"
  }
}

Updating root level values

PUT /admin/api/ecommerce/v1/products/1
{
  "name": "Product (English)"
}

will return

{
  ...,
  "name": "Product (English)",
  ...
}

Updating translations

PUT /admin/api/ecommerce/v1/products/1?include=translations
{
  "name": "Product (English)",
  "translations": {
    "name": {
      "en": "Product (something completely different)",
      "et": "Product (et)"
    }
  }
}

will return

{
  ...,
  "name": "Product (something completely different)",
  ...
}

Note that the root level name value is not used.