📘 公式リファレンス📦 リファレンス/オブジェクト中級
country オブジェクト
ストアの多言語・多通貨対応で利用可能な国の情報を保持するオブジェクト。国名、ISO コード、通貨、言語、大陸などのプロパティを参照できる。
用途
Shopify Markets で複数国対応しているストアで、国セレクターを実装したり、配送先の国に応じた通貨・言語表示を分岐したいとき。
設置場所
Liquid テンプレート内で、`localization.available_countries` や `localization.country`、`address.country` を通じて参照する。例えば、`{{ localization.country.name }}` で現在の国名、`{{ localization.country.iso_code }}` で ISO コード(JP など)を取得できる。
注意点
`popular?` プロパティはストアの人気配送地域を true / false で返すため、国セレクターで人気度順にソートするときに活用できる。`currency` は currency オブジェクト、`market` は market オブジェクトへの参照なので、それぞれのプロパティも連鎖参照可能。`image_url` フィルターに country オブジェクトを渡すと、その国の国旗 SVG(4:3 アスペクト比)の CDN URL が返される。
仕様
193 行 / json{
"access": {
"global": false,
"parents": [
{
"object": "localization",
"property": "available_countries"
},
{
"object": "localization",
"property": "country"
},
{
"object": "address",
"property": "country"
},
{
"object": "company_address",
"property": "country"
}
],
"template": []
},
"deprecated": false,
"deprecation_reason": "",
"description": "To learn how to use the `country` object to offer localization options in your theme,\nrefer to [Support multiple currencies and languages](/themes/internationalization/multiple-currencies-languages).",
"properties": [
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The name of the country.",
"name": "name"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The ISO code of the country in [ISO 3166-1 (alpha 2) format](https://www.iso.org/glossary-for-iso-3166.html).",
"name": "iso_code"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "string",
"name": "imperial",
"description": "",
"array_value": ""
},
{
"type": "string",
"name": "metric",
"description": "",
"array_value": ""
}
],
"summary": "The unit system of the country.",
"name": "unit_system"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "currency",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The currency used in the country.",
"name": "currency"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "market",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The market that includes this country.",
"name": "market"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if the country is popular for this shop. Otherwise, returns `false`.\nThis can be useful for sorting countries in a country selector.",
"name": "popular?"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "Possible values are `Africa`, `Asia`, `Central America`, `Europe`, `North America`, `Oceania`, and `South America`.",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The continent that the country is in.",
"name": "continent"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "array",
"name": "",
"description": "",
"array_value": "shop_locale"
}
],
"summary": "The languages that have been added to the market that this country belongs to.",
"name": "available_languages"
}
],
"summary": "A country supported by the store's localization options.",
"name": "country",
"examples": [
{
"name": "Referencing the `country` object directly",
"description": "When the country object is referenced directly, `country.name` is returned.\n",
"syntax": "",
"path": "/",
"raw_liquid": "{% for country in localization.available_countries -%}\n {{ country }}\n{%- endfor %}",
"parameter": false,
"display_type": "text",
"show_data_tab": true
},
{
"name": "Rendering a flag image",
"description": "When the country object is passed to the [`image_url`](/docs/api/liquid/filters#image_url) filter, a [CDN URL](/themes/best-practices/performance/platform#shopify-cdn) for that country’s flag is returned. All country’s flags are SVGs, normalized to an aspect ratio of 4:3.\n",
"syntax": "",
"path": "/",
"raw_liquid": "{{ localization.country | image_url: width: 32 | image_tag }}",
"parameter": false,
"display_type": "text",
"show_data_tab": true
}
],
"json_data": {
"path": "/",
"handle": "localization.country",
"data_from_file": ""
},
"return_type": []
}出典・ライセンス
- Repository:
- https://github.com/Shopify/theme-liquid-docs
- License:
- MIT
このコードは Shopify 著作の MIT ライセンスソースです。 原本の著作権は Shopify が保有します。日本語訳は ALSEL によるものです。
関連項目
📘 公式リファレンス📦 リファレンス/オブジェクト初級
content_for_header オブジェクト
Shopify が必要とするスクリプト(分析・チェックアウト・言語設定など)をすべて動的に出力するオブジェクト。theme.liquid の <head> タグ内に埋め込む必須要素。
📁 theme-liquid-docs·MIT·20 行
📘 公式リファレンス📦 リファレンス/オブジェクト中級
metaobjects オブジェクト
ストア全体のメタオブジェクト定義にアクセスするグローバルオブジェクト。個別のメタオブジェクトはタイプとハンドルで参照でき、メタオブジェクト定義のエントリをループで反復処理できる。
📁 theme-liquid-docs·MIT·20 行
📘 公式リファレンス📦 リファレンス/オブジェクト初級
additional_checkout_buttons オブジェクト
PayPal Express Checkout など、オフサイト決済に対応した外部決済プロバイダーがストアに設定されているかを真偽値で返す。`content_for_additional_checkout_buttons` と組み合わせて、該当するチェックアウトボタンを条件付きで表示する。
📁 theme-liquid-docs·MIT·27 行
📘 公式リファレンス📦 リファレンス/オブジェクト初級
canonical_url オブジェクト
現在のページの正規 URL を取得するオブジェクト。Google などの検索エンジンに対してどのページ版が正規であるかを指定するために使用する。
📁 theme-liquid-docs·MIT·27 行
📘 公式リファレンス📦 リファレンス/オブジェクト初級
content_for_index オブジェクト
ホームページに表示するセクションの内容を動的に返すオブジェクト。Liquid インデックステンプレートで必ず使用する。
📁 theme-liquid-docs·MIT·27 行
📘 公式リファレンス📦 リファレンス/オブジェクト初級
content_for_additional_checkout_buttons オブジェクト
PayPal、Apple Pay、Google Pay など複数の決済プロバイダが有効になっているとき、その決済ボタンを HTML として出力するオブジェクト。`additional_checkout_buttons` で有無を判定したうえで、このオブジェクトで実際のボタンを表示する。
📁 theme-liquid-docs·MIT·27 行