1
votes

Exporting discounted line items seems to be a common problem. I need to export the line item prices to my accounting software.

I'm trying to check for a coupon AND a specific product TAG, then apply the math with liquid to the actual discounted price.

I feel like I'm close but I'm striking out.

Any Advice would be much appreciated.

{% if line_items.tags contains '001' AND  line_items.discounts == true %}
    {{ line_item.price | times: .75 }}
{% else %}
    {{ line_item.price }}   
{% endif %}
1
thanks , I actually got it to work, but.. the problem I'm still stuck on is multiple discount codes. There is no way to know which code they used, that would apply to any line item that is tagged with a code and the customer used some other code. So if we have a 10% signup code, then a weekly 30% off code, and a 5% abandoned cart code or something. They all have to be tagged so I have to actually check which code they use (as best I can figure), but I have yet to figure out how to get Shopify to export the order.line_items.discount_codes.code ?? hmmmm...Casey

1 Answers

1
votes

Something like this?

{% for line_item in line_items %}
    {% if line_item.product.tags contains '001' and line_item.discounts %}
        {% assign rebate = 0 %}
        {% for discount in line_item.discounts %}
            {% if discount.type == 'PercentageDiscount' %}
                {% assign rebate = line_item.price | times:discount.amount %}
            {% endif %}
        {% endfor %}
        {{ line_item.price | minus:rebate }}
    {% else %}
        {{ line_item.price }}
    {% endif %}
{% endfor %}