Liquid、JavaScriptなどに関する質問
注文完了メールに表示される消費税がデフォルトだと税金合計となっているところを、
消費税8%と消費税10%で内訳を表示させるようにしたいです。
8%消費税 〇〇
10%消費税 〇〇
税金合計 〇〇
このように表示させることは可能でしょうか?
もしできるのであればその方法をご教授していただきたいです。
よろしくお願いいたします。
{% capture email_title %} {% if has_pending_payment %} ご注文頂きありがとうございました。 {% else %} ご購入頂きありがとうございました! {% endif %} {% endcapture %} {% capture email_body %} {% if has_pending_payment %} {% if buyer_action_required %} 支払い完了後、確認メールが届きます。 {% else %} 決済が処理されています。注文が確認されるとメールが届きます。 {% endif %} {% else %} {% if requires_shipping %} {% case delivery_method %} {% when 'pick-up' %} 注文の受取の準備が整うと、メールが届きます。 {% when 'local' %} {{ customer.last_name }}様、ご注文の品を配達する準備を行っております。 {% else %} 注文の発送準備を行なっております。商品を発送いたしましたら、改めてお知らせいたします。 {% endcase %} {% if delivery_instructions != blank %} <p><b>配達情報:</b> {{ delivery_instructions }}</p> {% endif %} {% if consolidated_estimated_delivery_time %} <p> 配達予定 <b>{{ consolidated_estimated_delivery_time }}</b> </p> {% endif %} {% endif %} {% endif %} {% assign gift_card_line_items = line_items | where: "gift_card" %} {% assign found_gift_card_with_recipient_email = false %} {% for line_item in gift_card_line_items %} {% if line_item.properties["__shopify_send_gift_card_to_recipient"] and line_item.properties["Recipient email"] %} {% assign found_gift_card_with_recipient_email = true %} {% break %} {% endif %} {% endfor %} {% if found_gift_card_with_recipient_email %} <p>ギフトカードの受取人には、ギフトカードコードが記載されたメールが届きます。</p> {% elsif gift_card_line_items.first %} <p>ギフトカードの個別のメールが届きます。</p> {% endif %} {% endcapture %} <!DOCTYPE html> <html lang="ja"> <head> <title>{{ email_title }}</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" type="text/css" href="/assets/notifications/styles.css"> <style> .button__cell { background: {{ shop.email_accent_color }}; } a, a:hover, a:active, a:visited { color: {{ shop.email_accent_color }}; } </style> </head> <body> <table class="body"> <tr> <td> <table class="header row"> <tr> <td class="header__cell"> <center> <table class="container"> <tr> <td> <table class="row"> <tr> <td class="shop-name__cell"> {%- if shop.email_logo_url %} <img src="{{shop.email_logo_url}}" alt="{{ shop.name }}" width="{{ shop.email_logo_width }}"> {%- else %} <h1 class="shop-name__text"> <a href="{{shop.url}}">{{ shop.name }}</a> </h1> {%- endif %} </td> <td> <tr> <td class="order-number__cell"> <span class="order-number__text"> 注文 {{ order_name }} </span> </td> </tr> {%- if po_number %} <tr> <td class="po-number__cell"> <span class="po-number__text"> 注文書番号 #{{ po_number }} </span> </td> </tr> {%- endif %} </td> </tr> </table> </td> </tr> </table> </center> </td> </tr> </table> <table class="row content"> <tr> <td class="content__cell"> <center> <table class="container"> <tr> <td> <h2>{{ email_title }}</h2> <p>{{ email_body }}</p> {% assign transaction_count = transactions | size %} {% if transaction_count > 0 %} {% for transaction in transactions %} {% if transaction.show_buyer_pending_payment_instructions? %} <p> {{transaction.buyer_pending_payment_notice}} </p> <p> <table class="row"> <tr> {% for instruction in transaction.buyer_pending_payment_instructions %} <td>{{ instruction.header }}</td> {% endfor %} <td>金額</td> </tr> <tr> {% for instruction in transaction.buyer_pending_payment_instructions %} <td>{{ instruction.value }}</td> {% endfor %} <td>{{transaction.amount | money}}</td> </tr> </table> </p> {% endif %} {% endfor%} {% endif %} {% if order_status_url %} <table class="row actions"> <tr> <td class="empty-line"> </td> </tr> <tr> <td class="actions__cell"> <table class="button main-action-cell"> <tr> <td class="button__cell"><a href="{{ order_status_url }}" class="button__text">注文を表示する</a></td> </tr> </table> {% if shop.url %} <table class="link secondary-action-cell"> <tr> <td class="link__cell">または<a href="{{ shop.url }}">ショップにアクセスする</a></td> </tr> </table> {% endif %} </td> </tr> </table> {% else %} {% if shop.url %} <table class="row actions"> <tr> <td class="actions__cell"> <table class="button main-action-cell"> <tr> <td class="button__cell"><a href="{{ shop.url }}" class="button__text">ショップにアクセスする</a></td> </tr> </table> </td> </tr> </table> {% endif %} {% endif %} </td> </tr> </table> </center> </td> </tr> </table> <table class="row section"> <tr> <td class="section__cell"> <center> <table class="container"> <tr> <td> <h3>注文概要</h3> </td> </tr> </table> <table class="container"> <tr> <td> <table class="row"> {% for line in subtotal_line_items %} <tr class="order-list__item"> <td class="order-list__item__cell"> <table> <td> {% if line.image %} <img src="{{ line | img_url: 'compact_cropped' }}" align="left" width="60" height="60" class="order-list__product-image"/> {% endif %} </td> <td class="order-list__product-description-cell"> {% if line.product.title %} {% assign line_title = line.product.title %} {% else %} {% assign line_title = line.title %} {% endif %} {% if line.quantity < line.quantity %} {% capture line_display %} {{ line.quantity }} of {{ line.quantity }} {% endcapture %} {% else %} {% assign line_display = line.quantity %} {% endif %} <span class="order-list__item-title">{{ line_title }} × {{ line_display }}</span><br/> {% if line.variant.title != 'Default Title' %} <span class="order-list__item-variant">{{ line.variant.title }}</span><br/> {% endif %} {% for group in line.groups %} <span class="order-list__item-variant">{{ group.display_title }}の一部</span><br/> {% endfor %} {% if line.gift_card and line.properties["__shopify_send_gift_card_to_recipient"] %} {% for property in line.properties %} {% assign property_first_char = property.first | slice: 0 %} {% if property.last != blank and property_first_char != '_' %} <div class="order-list__item-property"> <dt>{{ property.first }}:</dt> <dd> {% if property.last contains '/uploads/' %} <a href="{{ property.last }}" class="link" target="_blank"> {{ property.last | split: '/' | last }} </a> {% else %} {{ property.last }} {% endif %} </dd> </div> {% endif %} {% endfor %} {% endif %} {% if line.selling_plan_allocation %} <span class="order-list__item-variant">{{ line.selling_plan_allocation.selling_plan.name }}</span><br/> {% endif %} {% if line.refunded_quantity > 0 %} <span class="order-list__item-refunded">返金済み</span> {% endif %}
@むろ様
注文完了メールで消費税を8%と10%に分けて表示したい件ですが、
管理画面 > 設定 > 通知 > お客様通知 > 注文の確認 > コード編集を開き、下記コードの上部に
<tr class="subtotal-line">
<td class="subtotal-line__title">
<p>
<span>税金合計</span>
</p>
</td>
<td class="subtotal-line__value">
<strong>{{ tax_price | money }}</strong>
</td>
</tr>
下記コードを追加してください。
{%- for tax_line in order.tax_lines -%}
<tr class="subtotal-line">
<td class="subtotal-line__title">
<p>
<span>{{ tax_line.rate | times: 100 | floor }}% 消費税</span>
</p>
</td>
<td class="subtotal-line__value">
<strong>{{ tax_line.price | money }}</strong>
</td>
</tr>
{%- endfor -%}
以上で、下記のように表示されるかと思います。
ご参考まで。
(キュー小坂)
いつもShopifyをご利用いただき、ありがとうございます。 Shopifyは、皆様の日本語での利用体験の向上に努めております。さらなる改善のために皆様のご意見をお寄せい...
By JasonH May 9, 2025Shopify アカデミーの学習パスと認定スキルバッジExpanding Your Shopify Business Internationallyを活用して、国際的にビジネ...
By Shopify Feb 7, 2025Shopify アカデミーの学習パスB2B on Shopify:立ち上げとカスタマイズで卸売販売に進出しましょう。これら3つの無料コースは、ShopifyストアでB2B機能...
By Shopify Jan 31, 2025