📘 公式リファレンス📦 リファレンス/オブジェクト中級
discount_allocation オブジェクト
商品または配送方法に適用されたディスカウントの詳細情報。ディスカウント金額と適用元のディスカウント施策を保持する。
用途
顧客の注文履歴ページやカート画面で、各商品や配送料金に対してどのディスカウントが幾ら割引いたかを項目ごとに表示する場合に使用する。
設置場所
顧客の注文詳細や現在のカート内容を表示するテンプレート(customer/order.liquid など)で、`line_item.discount_allocations` または `shipping_method.discount_allocations` をループして、`discount_allocation.discount_application` と `discount_allocation.amount` を参照する。
注意点
`amount` は通貨の最小単位で出力されるため、JPY や KRW など補助単位を持たない通貨では 100 倍になる(例:1000 円 = 100000)。money フィルターで整形すれば自動補正されるため、`{{ discount_allocation.amount | money }}` として出力するとよい。`discount_application` は常に存在する(nil にならない)が、ディスカウント種別(割引率か固定額か)の判定は同オブジェクトの `type` プロパティで行う必要がある。
仕様
62 行 / json{
"access": {
"global": false,
"parents": [
{
"object": "line_item",
"property": "discount_allocations"
},
{
"object": "shipping_method",
"property": "discount_allocations"
}
],
"template": []
},
"deprecated": false,
"deprecation_reason": "",
"description": "To learn about how to display discounts in your theme, refer to [Discounts](/themes/pricing-payments/discounts).",
"properties": [
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "discount_application",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The discount application that applies the discount to the item.",
"name": "discount_application"
},
{
"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 amount.",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The amount that the item is discounted by in the currency's subunit.",
"name": "amount"
}
],
"summary": "Information about how a discount affects an item.",
"name": "discount_allocation",
"examples": [],
"json_data": {
"path": "/",
"handle": "customer.orders[2].line_items[0].discount_allocations[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 行