Liquid、JavaScriptなどに関する質問
お世話になります。
Order printerで、購入された商品の単品価格は出るのですが、商品の注文数に応じた合計金額を表示させたいです。
お分かりになりましたら、ご教示いただけると幸いです。
よろしくお願いいたします。
解決済! ベストソリューションを見る。
成功
ご質問いただいている、商品の合計額を表示したい件ですが、
商品の横軸に対しての合計額を表示したい認識で回答させて頂きます。
また、Order printerのソースコードにつきましては、
すでに変更を加えられていると思いますので、初期データを元に解説させて頂きます。
Order printerのテンプレート編集画面にて、初期表示で下記ソースコードとなっている部分を
<table class="table-tabular" style="margin: 0 0 1.5em 0;">
<thead>
<tr>
<th>Quantity</th>
<th>Item</th>
{% if show_line_item_taxes %}
<th>Taxes</th>
{% endif %}
<th>Price</th>
</tr>
</thead>
<tbody>
{% for line_item in line_items %}
<tr>
<td>{{ line_item.quantity }} x</td>
<td><b>{{ line_item.title }}</b></td>
{% if show_line_item_taxes %}
<td>
{% for tax_line in line_item.tax_lines %}
{{ tax_line.price | money }} {{ tax_line.title }}<br/>
{% endfor %}
</td>
{% endif %}
<td>
{% if line_item.original_price != line_item.price %}
<s>{{ line_item.original_price | money }}</s>
{% endif %}
{{ line_item.price | money }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
下記ソースコードに変更いただけましたら、横軸の右側に合計額することができます。
<table class="table-tabular" style="margin: 0 0 1.5em 0;">
<thead>
<tr>
<th>数量</th>
<th>商品</th>
{% if show_line_item_taxes %}
<th>消費税</th>
{% endif %}
<th>価格</th>
<th>合計額</th>
</tr>
</thead>
<tbody>
{% for line_item in line_items %}
<tr>
<td>{{ line_item.quantity }} x</td>
<td><b>{{ line_item.title }}</b></td>
{% if show_line_item_taxes %}
<td>
{% for tax_line in line_item.tax_lines %}
{{ tax_line.price | money }}<br/>
{% endfor %}
</td>
{% endif %}
<td>
{% if line_item.original_price != line_item.price %}
<s>{{ line_item.original_price | money }}</s>
{% endif %}
{{ line_item.price | money }}
</td>
<td>
{% assign total_price = line_item.price | times:line_item.quantity %}
{% for tax_line in line_item.tax_lines %}
{% assign total_price = total_price | plus:tax_line.price %}
{% endfor %}
{{ total_price | money }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
表示例
ご参考まで。
(キュー小坂)
成功
ご質問いただいている、商品の合計額を表示したい件ですが、
商品の横軸に対しての合計額を表示したい認識で回答させて頂きます。
また、Order printerのソースコードにつきましては、
すでに変更を加えられていると思いますので、初期データを元に解説させて頂きます。
Order printerのテンプレート編集画面にて、初期表示で下記ソースコードとなっている部分を
<table class="table-tabular" style="margin: 0 0 1.5em 0;">
<thead>
<tr>
<th>Quantity</th>
<th>Item</th>
{% if show_line_item_taxes %}
<th>Taxes</th>
{% endif %}
<th>Price</th>
</tr>
</thead>
<tbody>
{% for line_item in line_items %}
<tr>
<td>{{ line_item.quantity }} x</td>
<td><b>{{ line_item.title }}</b></td>
{% if show_line_item_taxes %}
<td>
{% for tax_line in line_item.tax_lines %}
{{ tax_line.price | money }} {{ tax_line.title }}<br/>
{% endfor %}
</td>
{% endif %}
<td>
{% if line_item.original_price != line_item.price %}
<s>{{ line_item.original_price | money }}</s>
{% endif %}
{{ line_item.price | money }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
下記ソースコードに変更いただけましたら、横軸の右側に合計額することができます。
<table class="table-tabular" style="margin: 0 0 1.5em 0;">
<thead>
<tr>
<th>数量</th>
<th>商品</th>
{% if show_line_item_taxes %}
<th>消費税</th>
{% endif %}
<th>価格</th>
<th>合計額</th>
</tr>
</thead>
<tbody>
{% for line_item in line_items %}
<tr>
<td>{{ line_item.quantity }} x</td>
<td><b>{{ line_item.title }}</b></td>
{% if show_line_item_taxes %}
<td>
{% for tax_line in line_item.tax_lines %}
{{ tax_line.price | money }}<br/>
{% endfor %}
</td>
{% endif %}
<td>
{% if line_item.original_price != line_item.price %}
<s>{{ line_item.original_price | money }}</s>
{% endif %}
{{ line_item.price | money }}
</td>
<td>
{% assign total_price = line_item.price | times:line_item.quantity %}
{% for tax_line in line_item.tax_lines %}
{% assign total_price = total_price | plus:tax_line.price %}
{% endfor %}
{{ total_price | money }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
表示例
ご参考まで。
(キュー小坂)
ご回答いただき、誠にありがとうございます。
コードの表記もしていただき、とても分かりやすく参考になりました。
無事に問題なく合計金額を表示することができました。
本当に助かりました!!
Maru369 様
お世話になっております。
ご質問確認しました。
liquidのorder → line_items → price & quantityのように、
order内のline_items内に、各line_itemのpriceとquantityが格納されているため、こちらを掛け算すれば合計金額を算出できるかと思います。
なにかヒントになれば幸いです。
私たちの励みにもなりますので、
お役に立てていればBest Answerボタンを押して頂ければ嬉しいです。
ご回答いただき、誠にありがとうございます。
参考にさせていただきます!!
ユーザー | ランク |
---|---|
35 | |
11 | |
7 | |
6 | |
6 |
すべてのShopifyアカウントはデフォルトではmyshopify.comのURLと関連付けられており、これはアカウント設定時に使用したビジネス名に基づいて作成されます。しかし、オ...
By Nina_13 Nov 26, 2023このトピックは英語版コミュニティの投稿:Shopify Web Pixel Manager Sandbox FAQの日本翻訳です。
By Mirai Nov 19, 2023Shopifyの管理画面では、商品ごとや配送元のロケーション(倉庫)ごとにカスタム配送料を設定することができます。特に購入金額による送料無料設定は、顧客の購買意欲を高める効果的な手...
By Alex06 Nov 5, 2023