
商品ページにラッピング選択を追加
Share
今回設定したい実装はこちら↓
①商品ページのカートに入れる前にラッピングのリボンの色を選択できる ②注文メールに選択したリボンの色が表記される |
バージョンやテーマによって記述が異なり少々戸惑ったので、備忘録にして残しておきます。
通常の実装で動作しない場合は以下の追加が必要です。
↓
「form属性」の確認:
form属性は、関連づけたいform要素のid属性と一致させる
【sections/main-product.liquid】
<!-- Liquid変数product_form_idの定義(赤文字が追加した箇所)-->
{%- assign product_form_id = 'product-form-' | append: section.id -%}
<!--
form要素外のinput要素。form属性に変数product_form_idを指定 -->
<input class="quantity__input" type="number" name="quantity" id="Quantity-{{ section.id }}" min="1" value="1" form="{{ product_form_id }}" > // id属性に変数product_form_idを指定 {%- form 'product', product, id: product_form_id, class: 'form', novalidate: 'novalidate', data-type: 'add-to-cart-form' -%}
{%- form 'product', product, id:product_form_id, class: 'ProductForm' -%}
---------------------------------------
liタグで選択ボックスを作成
〜〜省略〜〜
----------------------------------------
【お客様への注文確認メールに反映させる】
設定>通知>注文の確認
{% for line in subtotal_line_items %}内にコードを追加
{% assign property_size = line.properties | size %}
{% if property_size > 0 %}
{% for p in line.properties %}
{% assign first_character_in_key = p.first | truncate: 1, '' %}
{% unless p.last == blank or first_character_in_key == '_' %}
<span >{{ p.first }}: {{ p.last }}</span><br>
{% endunless %}
{% endfor %}
{% endif %}