1

I have two orders for the same product. One placed with a sale on the product enabled and the other with the same sale on the product disabled.

On the order details template for customers I have the following code

<table>
  {% for item in order.lineItems %}

    {% if item.purchasable.salesApplied|length or item.adjustments|length %}
      <tr>
        <th>Original Price</th>
        <td>{{ item.price|commerceCurrency(cart.currency) }}</td>
      </tr>
    {% endif %}

    {% if item.purchasable.salesApplied|length %}
      <tr>
        <th>{% for sale in item.purchasable.salesApplied %}{{ sale.name }}{% if not loop.last %} + {% endif %}{% endfor %}</th>
        <td>{{ item.saleAmount|commerceCurrency(cart.currency) }}</td>
      </tr>
    {% endif %}

    {% if item.adjustments|length %}
      {% for adjustment in item.adjustments %}
        <tr>
          <th>{{ adjustment.name }}</th>
          <td>{{ adjustment.amount|commerceCurrency(cart.currency) }}</td>
        </tr>
      {% endfor %}
    {% endif %}

    <tr>
      <th>
        {% if item.purchasable.salesApplied|length or item.adjustments|length %}
          Total
        {% endif %}
      </th>
      <td>{{ item.total|commerceCurrency(cart.currency) }}</td>
    </tr>

  {% endfor %}
</table>

I get the following results:

When placed: sale disabled
Currently: sale enabled

Original Price £150.00
25% off sale £0.00
Total £150.00

When placed: sale enabled
Currently: sale enabled

Original Price £150.00
25% off sale £47.50
Total £102.50

When placed: sale disabled
Currently: sale disabled

£150.00

When placed: sale enabled
Currently: sale disabled

£102.50

item.purchasable.salesApplied is reflecting the current sale status of the item rather than the status when the order was placed. Is there a way I can get the name and value of the actual sales that were applied at the time of purchase?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.