📘 公式リファレンス📦 リファレンス/オブジェクト初級
variant オブジェクト
商品のバリアント(色・サイズなどの組み合わせ)を表すオブジェクト。ID・タイトル・価格・在庫状況など、バリアント固有の情報にアクセスできる。
用途
商品詳細ページでバリアント一覧を表示したり、カート内の各商品がどのバリアントか判定したりするとき。
設置場所
Liquid テンプレート内で `{{ product.variants.first.title }}`、`{{ line_item.variant.id }}`、`{{ product.selected_variant.price }}` のように、product・line_item・gift_card オブジェクトから variant プロパティ経由でアクセスする。
注意点
selected プロパティは商品ページの URL パラメータ `?variant=` に基づくため、商品詳細ページでのみ機能する。コレクションページや検索結果では機能しない。matched プロパティはストアフロントフィルター適用時の可視性判定であり、在庫状況とは別。quantity_price_breaks は B2B カタログの数量階段価格設定が有効な場合にのみ値を持つ。
仕様
698 行 / json{
"access": {
"global": false,
"parents": [
{
"object": "line_item",
"property": "variant"
},
{
"object": "product",
"property": "first_available_variant"
},
{
"object": "product",
"property": "selected_or_first_available_variant"
},
{
"object": "product",
"property": "variants"
},
{
"object": "gift_card",
"property": "variant"
},
{
"object": "product",
"property": "selected_variant"
},
{
"object": "product_option_value",
"property": "variant"
},
{
"object": "remote_product",
"property": "selected_or_first_available_variant"
},
{
"object": "remote_product",
"property": "selected_variant"
},
{
"object": "remote_product",
"property": "first_available_variant"
}
],
"template": []
},
"deprecated": false,
"deprecation_reason": "",
"description": "",
"properties": [
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Tip:\n> To learn about how to create metafields, refer to [Create and manage metafields](/apps/metafields/manage) or visit\n> the [Shopify Help Center](https://help.shopify.com/manual/metafields).",
"examples": [],
"return_type": [
{
"type": "untyped",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The [metafields](/docs/api/liquid/objects/metafield) applied to the variant.",
"name": "metafields"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "product",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The parent product of the variant.",
"name": "product"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Note:\n> The selected variant is determined by the `variant` URL parameter. This URL parameter is available on product pages URLs only.",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if the variant is currently selected. Returns `false` if it's not.",
"name": "selected"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if the variant has been matched by a [storefront filter](https://shopify.dev/themes/navigation-search/filtering/storefront-filtering)\nor no filters are applied.\nReturns `false` if it hasn't.",
"name": "matched"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The ID of the variant.",
"name": "id"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [
{
"name": "The variant title",
"description": "",
"syntax": "",
"path": "/products/health-potion",
"raw_liquid": "{{ product.variants.first.title }}",
"parameter": false,
"display_type": "text",
"show_data_tab": true
}
],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "A concatenation of each variant option, separated by a `/`.",
"name": "title"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "If no rule exists, then a default value is returned.\n\nThis rule can be set as part of a [B2B catalog](https://help.shopify.com/manual/b2b/catalogs/quantity-pricing).\n\n> Note:\n> The default quantity rule is `min=1,max=null,increment=1`.",
"examples": [],
"return_type": [
{
"type": "quantity_rule",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The quantity rule for the variant.",
"name": "quantity_rule"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "array",
"name": "",
"description": "",
"array_value": "quantity_price_break"
}
],
"summary": "Returns `quantity_price_break` objects for the variant in the current customer context.",
"name": "quantity_price_breaks"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if the variant has any quantity price breaks available in the current customer context.\nReturns `false` if it doesn't.",
"name": "quantity_price_breaks_configured?"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "The value is output in the customer's local (presentment) currency.\n\nFor currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.\n\n> Tip:\n> Use [money filters](/docs/api/liquid/filters/money-filters) to output a formatted price.",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The price of the variant in the currency's subunit.",
"name": "price"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "The value is output in the customer's local (presentment) currency.\n\nFor currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.\n\n> Tip:\n> Use [money filters](/docs/api/liquid/filters/money-filters) to output a formatted price.",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The **compare at** price of the variant in the currency's subunit.",
"name": "compare_at_price"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "If no selling plan is selected, then `nil` is returned.\n\n> Note:\n> The selected selling plan is determined by the `selling_plan` URL parameter.",
"examples": [],
"return_type": [
{
"type": "selling_plan_allocation",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The selected `selling_plan_allocation`.",
"name": "selected_selling_plan_allocation"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "array",
"name": "",
"description": "",
"array_value": "selling_plan_allocation"
}
],
"summary": "The `selling_plan_allocation` objects for the variant.",
"name": "selling_plan_allocations"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The SKU of the variant.",
"name": "sku"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The barcode of the variant.",
"name": "barcode"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if the variant is available. Returns `false` if not.",
"name": "available"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [
{
"name": "Output the options of each variant",
"description": "",
"syntax": "",
"path": "/products/health-potion",
"raw_liquid": "{% for variant in product.variants -%}\n {%- capture options -%}\n {% for option in variant.options -%}\n {{ option }}{%- unless forloop.last -%}/{%- endunless -%}\n {%- endfor %}\n {%- endcapture -%}\n \n {{ variant.id }}: {{ options }}\n{%- endfor %}",
"parameter": false,
"display_type": "text",
"show_data_tab": true
}
],
"return_type": [
{
"type": "product_option_value",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The values of the variant for each [product option](/docs/api/liquid/objects/product_option).",
"name": "options"
},
{
"deprecated": true,
"deprecation_reason": "Deprecated. Prefer to use [`variant.options`](/docs/api/liquid/objects/variant#variant-options) instead.",
"description": "If there's no first product option, then `nil` is returned.",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The value of the variant for the first product option.",
"name": "option1"
},
{
"deprecated": true,
"deprecation_reason": "Deprecated. Prefer to use [`variant.options`](/docs/api/liquid/objects/variant#variant-options) instead.",
"description": "If there's no second product option, then `nil` is returned.",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The value of the variant for the second product option.",
"name": "option2"
},
{
"deprecated": true,
"deprecation_reason": "Deprecated. Prefer to use [`variant.options`](/docs/api/liquid/objects/variant#variant-options) instead.",
"description": "If there's no third product option, then `nil` is returned.",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The value of the variant for the third product option.",
"name": "option3"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "Variant URLs use the following structure:\n\n```\n/products/[product-handle]?variant=[variant-id]\n```",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The URL of the variant.",
"name": "url"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Tip:\n> To output the weight of a variant in this unit, use this property, and the `variant.weight_in_unit` property, with the\n> [`weight_with_unit` filter](/docs/api/liquid/filters/weight_with_unit).",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The unit for the weight of the variant.",
"name": "weight_unit"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Tip:\n> To output this weight, use this property, and the `variant.weight_unit` property, with the [`weight_with_unit` filter](/docs/api/liquid/filters/weight_with_unit).",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The weight of the variant in the unit specified by `variant.weight_unit`.",
"name": "weight_in_unit"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Tip:\n> Use the [`weight_with_unit`](/docs/api/liquid/filters/weight_with_unit) filter to format the weight in\n> [the store's format](https://www.shopify.com/admin/settings/general).\n>\n> Use `variant.weight_in_unit` to output the weight in the unit configured on the variant.",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The weight of the variant in grams.",
"name": "weight"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "To learn about how to display unit prices in your theme, refer to [Unit pricing](/themes/pricing-payments/unit-pricing).\n\n> Tip:\n> Use the [`unit_price_with_measurement` filter](/docs/api/liquid/filters/unit_price_with_measurement) with the\n> `variant.unit_price` property and this property to output a formatted unit price with measurement.",
"examples": [],
"return_type": [
{
"type": "unit_price_measurement",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The unit price measurement of the variant.",
"name": "unit_price_measurement"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "The price reflects any discounts that are applied to the line item. The value is output in the customer's local\n(presentment) currency.\n\nFor currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.\n\n> Tip:\n> Use the [`unit_price_with_measurement` filter](/docs/api/liquid/filters/unit_price_with_measurement) with this\n> property and the `variant.unit_price_measurement` property to output a formatted unit price with measurement.\n\nTo learn about how to display unit prices in your theme, refer to [Unit pricing](/themes/pricing-payments/unit-pricing).",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The [unit price](https://help.shopify.com/manual/products/details/product-pricing/unit-pricing#add-unit-prices-to-your-product)\nof the variant in the currency's subunit.",
"name": "unit_price"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "If inventory isn't tracked, then the number of items sold is returned.",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The inventory quantity of the variant.",
"name": "inventory_quantity"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "If inventory isn't tracked, then `nil` is returned.",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The inventory management service of the variant.",
"name": "inventory_management"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Tip:\n> To learn about why merchants might want to continue selling products when they're out of stock, visit the\n> [Shopify Help Center](https://help.shopify.com/manual/products/inventory/getting-started-with-inventory/selling-when-out-of-stock).",
"examples": [],
"return_type": [
{
"type": "string",
"name": "continue",
"description": "Continue selling when the variant is out of stock.",
"array_value": ""
},
{
"type": "string",
"name": "deny",
"description": "Stop selling when the variant is out of stock.",
"array_value": ""
}
],
"summary": "Whether the variant should continue to be sold when it's out of stock.",
"name": "inventory_policy"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if the variant requires shipping. Returns `false` if it doesn't.",
"name": "requires_shipping"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if taxes should be charged on the variant. Returns `false` if not.",
"name": "taxable"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Note:\n> This is the same value as [`variant.image`](/docs/api/liquid/objects/variant#variant-image).",
"examples": [],
"return_type": [
{
"type": "image",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The image attached to the variant.",
"name": "featured_image"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Note:\n> This is the same value as [`variant.featured_image`](/docs/api/liquid/objects/variant#variant-featured_image).",
"examples": [],
"return_type": [
{
"type": "image",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The image attached to the variant.",
"name": "image"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "media",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The first media object attached to the variant.",
"name": "featured_media"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "Incoming inventory information is populated by [inventory transfers](https://help.shopify.com/manual/products/inventory/transfers),\n[purchase orders](https://help.shopify.com/manual/products/inventory/purchase-orders), and\n[third-party apps](/docs/apps/fulfillment/inventory-management-apps).",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if the variant has incoming inventory. Returns `false` if not.",
"name": "incoming"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "Incoming inventory information is populated by [inventory transfers](https://help.shopify.com/manual/products/inventory/transfers),\n[purchase orders](https://help.shopify.com/manual/products/inventory/purchase-orders), and\n[third-party apps](/docs/apps/fulfillment/inventory-management-apps).\n\n> Tip:\n> Use the [`date` filter](/docs/api/liquid/filters/date) to format the date.",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The arrival date for the next incoming inventory of the variant.",
"name": "next_incoming_date"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "The array is defined in only the following cases:\n\n- `variant.selected` is `true`\n- The variant is the product's first available variant. For example, `product.first_available_variant` or `product.selected_or_first_available_variant`.",
"examples": [],
"return_type": [
{
"type": "array",
"name": "",
"description": "",
"array_value": "store_availability"
}
],
"summary": "The store availabilities for the variant.",
"name": "store_availabilities"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "boolean",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Returns `true` if the variant's product is set to require a `selling_plan` when being added to the cart. Returns `false` if not.",
"name": "requires_selling_plan"
}
],
"summary": "A [product variant](https://help.shopify.com/manual/products/variants).",
"name": "variant",
"examples": [],
"json_data": {
"path": "/products/health-potion",
"handle": "product.variants[0]",
"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 行