Liquid Snippets by ALSEL
📘 公式リファレンス📦 リファレンス/オブジェクト中級

unit_price_measurement オブジェクト

商品バリアントの単価測定情報を保持するオブジェクト。容積・重量・長さ・面積・個数などの単位でグラム当たりの価格を計算し、消費者に単価を提示するときに使う。

用途
商品詳細ページやカート画面で「100g当たり○円」のような単価表示を実装するとき。飲料・食品などの量り売り商品の価格透明性を高める。
設置場所
Liquid テンプレート内で `{{ variant.unit_price_measurement.measured_type }}` のように参照する。line_item のプロパティとしても `{{ item.unit_price_measurement.quantity_value }}` で呼び出せる。
注意点
Shopify 管理画面で該当バリアントに対して単価情報が設定されていることが前提。measured_type は「volume」「weight」「length」「area」「count」のいずれかの文字列が返される。quantity_value と reference_value は数値型のため、表示時に `| money` フィルターで通貨記号を付けるなど、フィルター処理が必要。unit_price_measurement が未設定のバリアントでは nil になるため、存在確認(`if variant.unit_price_measurement`)を忘れずに。
タグ:unit-priceproductvariantmeasurementpricing

仕様

134 行 / json
{
  "access": {
    "global": false,
    "parents": [
      {
        "object": "line_item",
        "property": "unit_price_measurement"
      },
      {
        "object": "variant",
        "property": "unit_price_measurement"
      }
    ],
    "template": []
  },
  "deprecated": false,
  "deprecation_reason": "",
  "description": "",
  "properties": [
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "volume",
          "description": "",
          "array_value": ""
        },
        {
          "type": "string",
          "name": "weight",
          "description": "",
          "array_value": ""
        },
        {
          "type": "string",
          "name": "length",
          "description": "",
          "array_value": ""
        },
        {
          "type": "string",
          "name": "area",
          "description": "",
          "array_value": ""
        },
        {
          "type": "string",
          "name": "count",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The type of unit measurement.",
      "name": "measured_type"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "number",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The quantity of the unit.",
      "name": "quantity_value"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The unit of measurement used to measure the [`quantity_value`](/docs/api/liquid/objects/unit_price_measurement#unit_price_measurement-quantity_value).",
      "name": "quantity_unit"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "number",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The quantity of the unit for the base unit price.",
      "name": "reference_value"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The unit of measurement used to measure the [`reference_value`](/docs/api/liquid/objects/unit_price_measurement#unit_price_measurement-reference_value).",
      "name": "reference_unit"
    }
  ],
  "summary": "Information about how units of a product variant are measured. It's used to calculate\n[unit prices](https://help.shopify.com/manual/products/details/product-pricing/unit-pricing#add-unit-prices-to-your-product).",
  "name": "unit_price_measurement",
  "examples": [],
  "json_data": {
    "path": "/",
    "handle": "customer.orders[1].line_items[0].unit_price_measurement",
    "data_from_file": ""
  },
  "return_type": []
}

出典・ライセンス

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