To update the template so it reflects the net quantity after partial refunds, follow these steps:
Solution1. Adjust the Template to Display Net Quantity:
Use a custom variable to calculate the net quantity based on refunded items.
Modify quantity in the loop to account for any refunds.
Here’s the modified code:
liquid
Copy code
{% for line_item in fulfilled_line_items %} {% unless line_item.quantity == 0 %} {%- assign net_quantity = line_item.quantity - line_item.refunded_quantity -%} {{ net_quantity }} x {{ line_item.title }} {% for property in line_item.properties %} {% if property.first contains '_io_' %}{% continue %}{% endif %} {% if property.last == blank %}{% continue %}{% endif %} {{ property.first }}: {{ property.last }} {% endfor %} {% if line_item.tax_lines %} {% for tax_line in line_item.tax_lines %} {{ tax_line.price | money }} {{ tax_line.title }} {% endfor %} {% endif %} {{ line_item.sku }} {{ line_item.price | money }} {% endunless %} {% endfor %}
Explanation:- {% assign net_quantity = line_item.quantity - line_item.refunded_quantity %} calculates the adjusted quantity by subtracting refunded items.
Display net_quantity instead of line_item.quantity in the template, showing the correct number after partial refunds.
Note:
Ensure that refunded_quantity is available in line_item data, or set up a back-end process to track and update this field.
Experience personalized shopping and real-time support with the Debales AI Chatbot on Shopify! Engage customers effortlessly and help them find the right products—let’s chat!
Please let us know if our reply is helpful by giving it a Like or marking it as a Solution!