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

filter オブジェクト

コレクションページや検索結果ページで利用可能なフィルター(絞り込み)の情報を表すオブジェクト。フィルターの種類、ラベル、選択値、URL パラメータなどにアクセスできる。

用途
コレクションページや検索結果に、ユーザーが商品を絞り込むためのフィルター UI(チェックボックス、スライダー、ドロップダウンなど)を実装するとき。フィルター条件の表示や、フィルター値の一覧を動的に生成する。
設置場所
collection または search オブジェクトの filters 配列をループ内で参照し、`{{ filter.label }}`、`{{ filter.type }}`、`{{ filter.values }}`などプロパティにアクセスする。主にコレクションテンプレート(templates/collection.liquid)や検索テンプレート(templates/search.liquid)内で使用。
注意点
filter オブジェクトは collection.filters または search.filters の配列内のみで利用可能で、グローバルには参照できない。boolean および list 型フィルターのみ active_values、inactive_values、values 配列を持ち、price_range 型では max_value プロパティが利用できる。Shopify 管理画面でフィルターが有効化されていないと、filters 配列が空になるため注意が必要。
タグ:filtercollectionsearchstorefront-filteringfaceted-search

仕様

284 行 / json
{
  "access": {
    "global": false,
    "parents": [
      {
        "object": "collection",
        "property": "filters"
      },
      {
        "object": "search",
        "property": "filters"
      }
    ],
    "template": []
  },
  "deprecated": false,
  "deprecation_reason": "",
  "description": "To learn about supporting filters in your theme, refer to [Support storefront filtering](/themes/navigation-search/filtering/storefront-filtering/support-storefront-filtering).",
  "properties": [
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The URL parameter for the filter. For example, `filter.v.option.color`.",
      "name": "param_name"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The customer-facing label for the filter.",
      "name": "label"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "Example:\nFor a filter named `color` with values `red` and `blue`:\n  - If the operator is `AND`, it will filter items that are both red and blue.\n  - If the operator is `OR`, it will filter items that are either red or blue or both.\n\nFilters that support the `AND` operator:\n  - Product tags\n  - Metafields of type `list.single_line_text_field` and `list.metaobject_reference`",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "AND",
          "description": "Includes products that match all buyer selections.",
          "array_value": ""
        },
        {
          "type": "string",
          "name": "OR",
          "description": "Includes products that match at least one buyer selection.",
          "array_value": ""
        }
      ],
      "summary": "The logical operator used by the filter.\nReturns a value only for `boolean` and `list` type filters. Returns `nil` for other types.",
      "name": "operator"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "boolean",
          "description": "",
          "array_value": ""
        },
        {
          "type": "string",
          "name": "list",
          "description": "",
          "array_value": ""
        },
        {
          "type": "string",
          "name": "price_range",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The type of the filter.",
      "name": "type"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "array",
          "name": "",
          "description": "",
          "array_value": "filter_value"
        }
      ],
      "summary": "The values of the filter that are currently active.\n\nThe array can have values only for `boolean` and `list` type filters.",
      "name": "active_values"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "The array can have values only for `boolean` and `list` type filters.",
      "examples": [],
      "return_type": [
        {
          "type": "array",
          "name": "",
          "description": "",
          "array_value": "filter_value"
        }
      ],
      "summary": "The values of the filter that are currently inactive.",
      "name": "inactive_values"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "array",
          "name": "",
          "description": "",
          "array_value": "filter_value"
        }
      ],
      "summary": "The values of the filter.\n\nThe array can have values only for `boolean` and `list` type filters.",
      "name": "values"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "filter_value",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The `false` filter value.\n\nReturns a value for `boolean` type filters if the unfiltered view has at least one result with the `false` filter value. Otherwise, it returns `nil`.",
      "name": "false_value"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "filter_value",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The `true` filter value.\n\nReturns a value for `boolean` type filters if the unfiltered view has at least one result with the `true` filter value. Otherwise, it returns `nil`.",
      "name": "true_value"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "filter_value",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The highest filter value.\n\nReturns a value only for `price_range` type filters. Returns `nil` for other types.",
      "name": "max_value"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "filter_value",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The lowest filter value.\n\nReturns a value only for `price_range` type filters. Returns `nil` for other types.",
      "name": "min_value"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "number",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The highest product price within the collection or search results.\n\nReturns a value only for `price_range` type filters. Returns `nil` for other types.",
      "name": "range_max"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "The current page URL with the URL parameter related to the filter removed.",
      "name": "url_to_remove"
    },
    {
      "deprecated": false,
      "deprecation_reason": "",
      "description": "",
      "examples": [],
      "return_type": [
        {
          "type": "string",
          "name": "image",
          "description": "",
          "array_value": ""
        },
        {
          "type": "string",
          "name": "swatch",
          "description": "",
          "array_value": ""
        },
        {
          "type": "string",
          "name": "text",
          "description": "",
          "array_value": ""
        }
      ],
      "summary": "Describes how to present the filter values.\n\nReturns a value only for `list` type filters. Returns `nil` for other types.",
      "name": "presentation"
    }
  ],
  "summary": "A [storefront filter](https://help.shopify.com/manual/online-store/themes/customizing-themes/storefront-filters).",
  "name": "filter",
  "examples": [],
  "json_data": {
    "path": "/search?q=potion&filter.v.option.strength=Low",
    "handle": "search.filters.to_a[3]",
    "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