LoginSignup
6

More than 1 year has passed since last update.

【Shopify】liquidのオブジェクトについてまとめてみた (tax_line, template, theme)

Last updated at Posted at 2021-02-26

はじめに

この記事は、Liquid オブジェクトについて日本語訳したものです。

tax_line, template, themeオブジェクトをまとめていきます。

tax_line オブジェクト

tax_lineオブジェクトの属性についてみていきます。

tax_line.price

tax_line.priceは、税金の金額を返します。
この金額は、顧客の現地通貨で表示されます。money filtersのいずれかを使用して、設定した金額形式で返します。

Input
{{ tax_line.price | money }}
Output
¥2,500

tax_line.rate

tax_line.rateは、税率を10進数で返します。

Input
{{ tax_line.rate }}
Output
0.10

tax_line.rate_percentage

tax_line.rate_percentageは、税率をパーセンテージ形式で返します。

Input
{{ tax_line.rate_percentage }}%
Output
10%

tax_line.title

tax_line.titleは、税金のタイトルを返します。

Input
{{ tax_line.title }}
Output
GST

templete オブジェクト

templeteオブジェクトは、一握りの属性があります。

templateだけを参照すると、現在のページをレンダリングするために使用されるテンプレートの名前を返します。

Input
<!--  page.contact.liquid template が使用される場合は -->
{{ template }}
Output
page.contact

template.directory

template.directoryは、テンプレートの親ディレクトリの名前を返します。
親ディレクトリがtemplates/フォルダであるテンプレートの場合はnilを返します。

Input
<!--  customers/login.liquid template の場合 -->
{{ template.directory }}
Output
customers

template.name

template.nameは、テンプレートのカスタムサフィックスが存在する場合はテンプレート名を、.liquid拡張子が存在する場合は.liquid拡張子を除いたテンプレート名を返します。

Input
<!-- product.alternate.liquid template の場合 -->
{{ template.name }}
Output
product

template.suffix

template.suffixは、template.nameプリフィックス、または.liquid拡張子を除いたカスタムテンプレートの名前を返します。カスタムテンプレートを使用していない場合はnilを返します。

Input
<!-- product.alternate.liquid template の場合 -->
{{ template.suffix }}
Output
alternate

theme オブジェクト

themeオブジェクトには、ストアの公開テーマに関する情報が含まれています。

themeオブジェクトの属性についてみてみます。

theme.id

theme.idは、テーマのIDを返します。これは、ユーザーをテーマエディタに直接リンクさせたい場合に便利です。

Input
Visit the <a href="/admin/themes/{{ theme.id }}/settings">theme editor</a> to change your logo.
Output
Visit the <a href="/admin/themes/8196497/settings">theme editor</a> to change your logo.

theme.name

theme.nameは、テーマの名前を返します。

終わりに

今回の記事はここまでになります。
お疲れ様でした。

Shopify アプリのご紹介

Shopify アプリである、「商品ページ発売予告アプリ | リテリア Coming Soon」は、商品ページを買えない状態のまま、発売日時の予告をすることができるアプリです。Shopify で Coming Soon 機能を実現することができます。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6