📘 公式リファレンス📦 リファレンス/オブジェクト初級
discount オブジェクト
カート、商品行、注文に適用された割引情報を保持するオブジェクト。割引額、種類、割引コード/タイトルを取得できる。
用途
カート内容確認画面や注文確認画面で、適用された割引の金額や名前をユーザーに表示するとき。
設置場所
Liquid 内で `{{ cart.discounts[0].amount }}` や `{{ order.discounts[0].title }}` のように参照する。cart、line_item、order、checkout オブジェクトの discounts プロパティを通じてアクセス可能。
注意点
このオブジェクトは廃止予定となり、discount_allocation および discount_application オブジェクトに置き換わっている。すべての割引タイプと詳細情報をキャプチャできないため、新規実装では discount_application オブジェクトの使用を推奨。JPY や KRW など小数単位を持たない通貨では、金額が100倍で出力される(例:1000 円は 100000 として出力)ため、money フィルターで整形して表示すること。
仕様
162 行 / json{
"access": {
"global": false,
"parents": [
{
"object": "cart",
"property": "discounts"
},
{
"object": "line_item",
"property": "discounts"
},
{
"object": "order",
"property": "discounts"
},
{
"object": "checkout",
"property": "discount"
}
],
"template": []
},
"deprecated": true,
"deprecation_reason": "Deprecated because not all discount types and details are captured.\n\nThe `discount` object has been replaced by the [`discount_allocation`](/docs/api/liquid/objects/discount_allocation) and\n[`discount_application`](/docs/api/liquid/objects/discount_application) objects.",
"description": "",
"properties": [
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Note:\n> This is the same value as [`discount.total_amount`](/docs/api/liquid/objects/discount#discount-total_amount).\n\nThe 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 amount.",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The amount of the discount in the currency's subunit.",
"name": "amount"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Note:\n> This is the same value as [`discount.amount`](/docs/api/liquid/objects/discount#discount-amount).\n\nThe 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 amount.",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The amount of the discount in the currency's subunit.",
"name": "total_amount"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Note:\n> This is the same value as [`discount.title`](/docs/api/liquid/objects/discount#discount-title).",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The customer-facing name of the discount.",
"name": "code"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Note:\n> This is the same value as [`discount.code`](/docs/api/liquid/objects/discount#discount-code).",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The customer-facing name of the discount.",
"name": "title"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "string",
"name": "FixedAmountDiscount",
"description": "",
"array_value": ""
},
{
"type": "string",
"name": "PercentageDiscount",
"description": "",
"array_value": ""
},
{
"type": "string",
"name": "ShippingDiscount",
"description": "",
"array_value": ""
}
],
"summary": "The type of the discount.",
"name": "type"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Note:\n> This is the same value as [`discount.total_savings`](/docs/api/liquid/objects/discount#discount-total_savings).\nThe 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 amount.",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The amount of the discount as a negative value, in the currency's subunit.",
"name": "savings"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "> Note:\n> This is the same value as [`discount.savings`](/docs/api/liquid/objects/discount#discount-savings).\nThe 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 amount.",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The amount of the discount as a negative value, in the currency's subunit.",
"name": "total_savings"
}
],
"summary": "A discount applied to a cart, line item, or order.",
"name": "discount",
"examples": [],
"json_data": {
"path": "/",
"handle": "customer.orders[2].discounts[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 行