Liquid Snippets by ALSEL
📘 公式リファレンス🔧 リファレンス/フィルター初級

unit_price_with_measurement フィルター(単価と計量単位の表示)

商品バリアントの単価と計量単位(容量、重量など)を組み合わせて、ストアの通貨設定に応じた形式で表示する。

用途
食品や日用雑貨など計量販売する商品の詳細ページで、「100 円/100g」のように単価と単位を組み合わせて表示したいとき。
設置場所
product.liquid 内で `{{ variant.unit_price | unit_price_with_measurement: variant.unit_price_measurement }}` の形で使う。先に money フィルターを適用する場合は `{{ variant.unit_price | money_with_currency | unit_price_with_measurement: variant.unit_price_measurement }}` とつなぐ。
注意点
バリアントの unit_price と unit_price_measurement が両方設定されていることが前提。管理画面で計量単位を未設定だと正しく表示されないため、商品詳細ページで「価格設定」セクションの「単価」と「単価の単位」を入力しておく必要がある。通貨記号の有無はストアの通貨書式設定(HTML なし設定)に準じて自動的に決まる。
タグ:filterunit-pricemeasurementproductformat

仕様

40 行 / json
{
  "category": "format",
  "deprecated": false,
  "deprecation_reason": "",
  "description": "",
  "parameters": [],
  "return_type": [
    {
      "type": "string",
      "name": "",
      "description": "",
      "array_value": ""
    }
  ],
  "examples": [
    {
      "name": "",
      "description": "",
      "syntax": "",
      "path": "/products/blue-mountain-flower",
      "raw_liquid": "{%- assign variant = product.variants.first -%}\n\n{{ variant.unit_price | unit_price_with_measurement: variant.unit_price_measurement }}",
      "parameter": false,
      "display_type": "text",
      "show_data_tab": true
    },
    {
      "name": "Formatted unit price",
      "description": "You can specify a formatted unit price using one of the [money filters](/docs/api/liquid/filters/payment_button#money-filters).",
      "syntax": "string | unit_price_with_measurement: unit_price_measurement",
      "path": "/products/blue-mountain-flower",
      "raw_liquid": "{%- assign variant = product.variants.first -%}\n\n{{ variant.unit_price | money_with_currency | unit_price_with_measurement: variant.unit_price_measurement }}",
      "parameter": true,
      "display_type": "text",
      "show_data_tab": true
    }
  ],
  "summary": "Formats a given unit price and measurement based on the store's [**HTML without currency** setting](https://help.shopify.com/manual/payments/currency-formatting).",
  "syntax": "number | unit_price_with_measurement: unit_price_measurement",
  "name": "unit_price_with_measurement"
}

出典・ライセンス

License:
MIT

このコードは Shopify 著作の MIT ライセンスソースです。 原本の著作権は Shopify が保有します。日本語訳は ALSEL によるものです。

関連項目

📘 公式リファレンス🔧 リファレンス/フィルター初級

avatar フィルター(顧客アバター画像HTML生成)

顧客アバターが存在する場合、それを表示する HTML タグを生成するフィルター。customer オブジェクトに対して使用する。

📁 theme-liquid-docs·MIT·19
📘 公式リファレンス🔧 リファレンス/フィルター初級

default_errors フィルター(フォーム送信エラーを日本語化)

form.errors の各エラーコードに対応する既定のエラーメッセージを自動生成するフィルター。フォーム送信時の入力値不正や必須項目空白などのエラーを言語別に出力する。

📁 theme-liquid-docs·MIT·19
📘 公式リファレンス🔧 リファレンス/フィルター初級

date フィルター(日付を指定形式でフォーマット)

日付値を指定されたフォーマット文字列に従って整形する。フォーマット文字列が空の場合は元の値がそのまま返される。入力が日付に変換できない場合も元の値が返される。

📁 theme-liquid-docs·MIT·19
📘 公式リファレンス🔧 リファレンス/フィルター初級

payment_terms フィルター(Shop Pay分割払いバナーを生成)

product フォームまたは cart フォームに対して使用し、Shop Pay の分割払いオプションを表示するための HTML を生成するフィルター。顧客が購入時に分割払いプランを選択できるようにする。

📁 theme-liquid-docs·MIT·19
📘 公式リファレンス🔧 リファレンス/フィルター初級

abs フィルター(数値の絶対値を取得)

負の数を正の数に変換する。数値の絶対値(ゼロからの距離)を返すフィルター。

📁 theme-liquid-docs·MIT·30
📘 公式リファレンス🔧 リファレンス/フィルター初級

append フィルター(文字列の末尾に追加)

文字列の末尾に別の文字列を連結するフィルター。URL パスの結合やテキストの接尾辞追加に使う。

📁 theme-liquid-docs·MIT·30