複数個購入時の代金表示について

設定 > 配送と配達 > 明細表 > 明細表のテンプレートにて、明細票を作成しています。

後述のように組んでいるのですが、「小計」が 価格 × 数量の計算結果にならず、単体価格が表示されてしまいます。(添付画像の表を参照ください)

購入した数量は表示されているのに、final_line_priceを使っても表示されないのはなぜでしょうか?

また、「商品金額合計」や「合計金額」も正しく表示されないのは、なぜでしょうか?

間違っている部分などを教えていただければ幸いです。よろしくお願いします。

{% assign final_price = nil %}
        {% assign final_line_price = nil %}
        {% for item in order.line_items %}
          {% assign final_price = item.final_price %}
          {% assign final_line_price = item.final_line_price %}
        {% endfor %}

        {% for line_item in line_items_in_shipment %}
          
            
              {% if line_item.image != blank %}
                
              {% endif %}
            
            {{ line_item.title }}
            
              {% if final_price %}
                {{ final_price | money }}
              {% endif %}
            {{ line_item.quantity }}
            
              {% if final_line_price %}
                {{ final_line_price | money }}
              {% endif %}
          
        {% endfor %}

      <table>

        
          
            <tr>

              <th>

商品金額合計

</th>

              <td>

                {{ order.line_items_subtotal_price | money }}
              

</td>

            </tr>

            <tr>

              <th>

送料

</th>

              <td>

{{ order.shipping_price | money }}

</td>

            </tr>

            <tr>

              <th>

合計金額

</th>

              <td>

{{ order.total_price | money  }}

</td>

            </tr>

            
          
        
      </table>

単価 × 数量 で小計を算出してみてはどうでしょうか。

{% assign a = final_price %}
{% assign b = line_item.quantity %}

小計 {{ a | times:b | money }}
2 Likes

ありがとうございます!