跳至內容
ShopentlyLearn

情境

商店情境包含可用語言和銷售市場的資訊。取得情境後,你可以查看各自的代碼與識別碼、預設語言及基礎市場。之後的請求需要選擇語言或市場時,可以使用這些資訊。

languages
商店可用的語言及其代碼。
markets
銷售市場及其識別碼和貨幣。
default_locale
商店預設語言代碼。
base_market_id
商店基礎市場的識別碼。

取得 · 內容情境

此請求需要存取權杖。

GET/api/v1/context

cURL 請求

curl --disable --globoff --fail-with-body --silent --show-error \
  --proto '=https' --connect-timeout 5 --max-time 30 \
  --request GET \
  --url https://shop.onshopently.com/api/v1/context \
  --header 'Authorization: Bearer EXAMPLE_ACCESS_TOKEN'

回應

{
  "data": {
    "base_market_id": "example",
    "default_locale": "en",
    "global_enabled": false,
    "languages": [
      {
        "code": "en",
        "direction": "ltr",
        "is_default": true,
        "name": "English",
        "native_name": "English",
        "status": "draft"
      }
    ],
    "markets": [
      {
        "code": "PL",
        "currency": {
          "code": "PLN",
          "minor_units": 2
        },
        "id": "example",
        "is_default": true,
        "name": "Poland",
        "price_list": null,
        "status": "draft"
      }
    ],
    "multilingual_enabled": false
  },
  "meta": {
    "locale": "en",
    "market_code": "PL",
    "market_id": "example",
    "request_id": "example"
  }
}

選擇語言

取得商店內容時,請選擇希望使用的語言。語言代碼可在情境請求的回應中找到。

語言和市場需要分別選擇。選擇德語並不會自動選擇德國市場。