はじめに
この記事は、Liquid オブジェクトについて日本語訳したものです。
selling_plan, selling_plan_allocation, selling_plan_groupオブジェクトをまとめていきます。
またこれらのオブジェクトはいずれもBetaとの表示があります。
selling_plan オブジェクト
selling_plan オブジェクトは、ライン・アイテムに適用された販売計画の意図をキャプチャします。
selling_planの属性についてそれぞれ見ていきます。
selling_plan.description
selling_plan.descriptionは、販売プランの説明を返します。
selling_plan.group_id
selling_plan.group_idは、販売プランが属するselling_plan_groupの一意のIDを返します。
同じアプリで作成され、同じselling_plan_group.nameとselling_plan_group_option.nameの値を持つ販売プラングループは、製品オブジェクト上で同じselling_plan_groupに結合されます。
selling_plan.id
selling_plan.idは、販売プランの一意のIDを返します。
この値は、カートにselling_planを送信する際に使用されます。
<select name="selling_plan">
{% for variant in product.variants %}
<optgroup label="{{ variant.title }}">
{% for allocation in variant.selling_plan_allocations %}
<option value="{{ allocation.selling_plan.id }}">
{{ allocation.selling_plan.name }}
</option>
{% endfor %}
</optgroup>
{% endfor %}
</select>
<select name="selling_plan">
<optgroup label="Coffee">
<option value="1425">1-month subscription</option>
<option value="3642">6-month subscription</option>
<option value="3260">1-year subscription</option>
</optgroup>
<optgroup label="Tea">
<option value="1425">1-month subscription</option>
<option value="3642">6-month subscription</option>
<option value="3260">1-year subscription</option>
</optgroup>
</select>
selling_plan.name
selling_plan.nameは、販売プランの名前を返します。
販売プランの名前は、チェックアウト時にラインアイテムのご注文概要に表示されます。
selling_plan.options
selling_plan.optionsは、特定の selling_plan_group_option に対する販売プランの値に関する情報を含む selling_plan_option オブジェクトの配列を返します。
selling_plan_option.name
selling_plan_option.nameは、販売プラングループのオプション名です。
selling_plan_option.position
selling_plan_option.positionは、すべての selling_plan_group.options の中のオプションのインデックスです。
selling_plan_option.value
selling_plan_option.valueは、販売プランのオプションの値です。
この値は、selling_plan_group_option.values 配列の項目の1つです。
{% for option in selling_plan.options %}
{{ option.name }} : {{ option.value }}
{% endfor %}
Delivery frequency : Every month
Payment frequency : Pay per delivery
selling_plan.price_adjustments
selling_plan.price_adjustmentsは、selling_plan_price_adjustment オブジェクトの配列を返します。selling_plan_price_adjustment は、販売計画が指定された期間のバリアントの価格をどのように変更するかを説明します。
配列の最大長は2です。 販売計画が価格調整を行わない場合は、配列は空です。
販売プランの各 selling_plan_price_adjustment は、selling_plan_allocation 配列の selling_plan_allocation_price_adjustment に対応します。selling_plan.price_adjustmentsには販売プランの意図が記述され、 selling_plan_allocation.price_adjustmentsには結果として得られる金額が記述されています。
Pay {{ selling_plan_allocation.price_adjustments[0].price | money }} on
the first {{ selling_plan.price_adjustments[0].order_count }} orders.
Pay $100.00 on the first 3 orders.
price_adjustment.order_count
price_adjustment.order_countは、この価格調整が適用される注文数です。
価格調整が継続的に適用されている場合、または売却プランの残りの期間に適用されている場合は、価値はnilです。
price_adjustment.position
price_adjustment.positionは、selling_plan.price_adjustments配列のprice_adjustmentの1ベースのインデックスです。
positionの値は、selling_plan_allocation.price_adjustments配列内の結果のselling_plan_allocation_price_adjustmentsを参照するために使用することができます。
price_adjustment.value
price_adjustment.valueは、価格調整の値を表すフロートです。
価格調整の値の型によって、この値の解釈方法が変わります。
例えば、price_adjustment.valueが100.00の場合:
-
price_adjustment.value_typeが「パーセンテージ」の場合、価格調整は100%となります。 -
price_adjustment.value_typeが「fixed_amount」または「price」の場合、価格調整は$100.00となります。
price_adjustment.value_type
price_adjustment.value_typeは、価格調整の種類です。
可能な値は以下の通りです:
-
percentage: 販売価格を一定の割合で引き下げる -
fixed_amount: 販売価格を1ドル単位で引き下げる -
price: バリアントに対して特定の販売価格を設定
selling_plan.recurring_deliveries
selling_plan.recurring_deliveriesは、販売プランに複数の定期的な配送が含まれている場合にtrueを返します。
selling_plan.selected
selling_plan.selectedは、販売計画の ID が selling_plan URL パラメータで特定されている場合に true を返します。
selling_plan_allocation オブジェクト
selling_plan_allocationは、特定の販売プランがどのようにラインアイテムに影響を与えるかを表します。selling_plan_allocationは、バリアントを販売プランに関連付けます。
販売プランに複数の配送が含まれている場合、例えば 12 ヶ月のプリペイド契約など、価格と compare_at_price の値に配送数が乗算されます。
selling_plan_allocation.compare_at_price
selling_plan_allocation.compare_at_priceは、販売プラン割り当ての比較価格です。
この値は、販売プランが適用されていない場合の variant の価格に設定されます。販売プランが適用された variant の価格が同じ場合、この値はnilになります。
selling_plan_allocation.per_delivery_price
selling_plan_allocation.per_delivery_priceは、販売プランに含まれる各配送ごとに課金される価格です
販売プランに複数の配送が含まれている場合、配送ごとの価格は、selling_plan_allocation.priceを配送数で割った値になります。
{{ selling_plan_allocation.price | money }}
{% if selling_plan_allocation.per_delivery_price != selling_plan_allocation.price %}
({{selling_plan_allocation.per_delivery_price }} each)
{% endif %}
$1,200.00 ($100.00 each)
selling_plan_allocation.price
selling_plan_allocation.priceは、販売プランが適用されたラインアイテムの価格です。
selling_plan_allocation.price_adjustments
selling_plan_allocation.price_adjustmentsは、selling_plan_allocation_price_adjustment オブジェクトの配列です。
配列の最大長は2です。 販売プランが価格調整を作成していない場合、この配列は空です。
販売計画の各selling_plan_allocation_price_adjustmentは、selling_plan.price_adjustments配列内のselling_plan_price_adjustmentにマッピングされます。selling_plan.price_adjustmentsには販売プランの意図が記述され、selling_plan_allocation.price_adjustmentsには結果として得られる金額が記述されます。
Pay {{ selling_plan_allocation.price_adjustments[0].price | money }} on
the first {{ selling_plan.price_adjustments[0].order_count }} orders.
Pay $100.00 on the first 3 orders.
price_adjustment.position
selling_plan_allocation.price_adjustments配列のprice_adjustmentsの1ベースのインデックスです。
position値は、selling_plan.price_adjustments配列内の関連するselling_plan_price_adjustmentを参照するために使用することができます。
price_adjustment.price
price_adjustment期間中に請求される価格です。
selling_plan_allocation.selling_plan
selling_plan_allocation.selling_planは、割り振りを作った販売プランです。
selling_plan_allocation.selling_plan_group_id
selling_plan_allocation.selling_plan_group_idは、アロケーションの販売プランが属するselling_plan_groupのID。
selling_plan_allocation.unit_price
selling_plan_allocation.unit_priceは、販売計画に関連付けられた variant の単価です。
variant に単価がない場合、このプロパティは nil を返します。
selling_plan_group オブジェクト
selling_plan_groupオブジェクトは、商品の一部またはすべてのバリエーションで利用可能な販売プランのグループです。グループ内の販売プランはすべて同じ selling_plan_option.name 値を共有します。
同じアプリで作成され、同じselling_plan_group.nameとselling_plan_group.optionsの値を持つ販売プラングループは、Liquidの同じproduct.selling_plan_groupにマージされます。このマージにより、selling_plan_groupの配列のLiquid値の冗長性がなくなります。
{% for selling_plan_group in product.selling_plan_groups %}
{{ selling_plan_group.name }} :
{% for selling_plan in selling_plan_group.selling_plans %}
- {{ selling_plan.name }}
{% endfor %}
{% endfor %}
Subscribe & save:
- Weekly (save 10%)
- Monthly (save 5%)
Prepaid subscriptions:
- Prepaid for 1 year
selling_plan_group.id
selling_plan_group.idは、販売プラングループの一意のIDです。
selling_plan_group.name
selling_plan_group.nameは、販売プラングループ名です。
selling_plan_group.options
selling_plan_group.optionsは、selling_plan_group_option オブジェクトの配列です。
selling_plan_group_option オブジェクトには、selling_plan_group.option 配列内の個々の項目の名前とそれぞれの値が含まれます。
{% for option in selling_plan_group.options %}
<label>{{ option.name }}</label>
<select>
{% for value in option.values %}
<option {% if value == option.selected_value %}selected{% endif %}>
{{ value }}
</option>
{% endfor %}
</select>
{% endfor %}
<label>Delivery frequency</label>
<select>
<option>Every week (save 10%)</option>
<option selected>Every month (save 5%)</option>
<option>Every 2 months (save 5%)</option>
</select>
selling_plan_group_option.name
selling_plan_group_option.nameは、販売プランオプションの名前を返します。
selling_plan_group_option.position
selling_plan_group_option.positionは、すべての selling_plan_group.options の中のオプションのインデックスを返します。
selling_plan_group_option.selected_value
selling_plan_group_option.selected_valueは、 selling plan allocation を選択した場合の販売計画プラングループオプションの値を返します。選択された販売計画の割り当ては、URL パラメータ selling_plan と id の両方に基づいています
selling_plan_group_option.values
selling_plan_group_option.valuesは、販売プラングループオプションの値の配列です。
selling_plan_group.selling_plan_selected
selling_plan_group.selling_plan_selectedは、選択した販売プランが販売プラングループの一部である場合に true を返します。選択した販売プランは、URL パラメータ selling_plan に基づいています。
selling_plan_group.selling_plans
selling_plan_group.selling_plansは、selling_plan_group に属する selling_plan オブジェクトの配列です。
selling_plan_group.app_id
selling_plan_group.app_idは、アプリによって提供されるオプションの文字列で、そのアプリによって作成された販売プラングループを識別します。
アプリから文字列が提供されない場合、このプロパティはnilを返します。
例えば、アプリが app_id が "yourApp" の販売プラングループを作成した場合、where フィルタを使用して、これらの販売プラングループのみの配列を作成することができます。
{% assign filtered_groups = product.selling_plan_groups | where: "app_id", "yourApp" %}
Total selling plan groups: {{ product.selling_plan_groups.size }}
Filtered selling plan groups: {{ filtered_groups.size }}
Total selling plan groups: 3
Filtered selling plan groups: 1
終わりに
今回の記事はここまでになります。
お疲れ様でした。
Shopify アプリのご紹介
Shopify アプリである、「商品ページ発売予告アプリ | リテリア Coming Soon」は、商品ページを買えない状態のまま、発売日時の予告をすることができるアプリです。Shopify で Coming Soon 機能を実現することができます。