2

On my cart page I have the coupon code form to apply discounts to the order. Underneath the form I want to list all the coupons applied to the cart with an button to remove each discount.

As in the example template I can access the latest coupon applied to the cart, but am no sure how to list all that have been applied to the cart and how to remove a coupon if a customer wanted to.

Thank you.

2

You've sort of answered your own question - Commerce only allows one coupon on a cart at any time (currently).

To determine if a coupon is set, and print the code, it's basically:

{% if cart.couponCode %}
     {{ cart.couponCode }}
{% endif %}

You CAN have discounts applied as well as coupons, though. With those, you can look through with something like this (removing the coupons if you've previously printed that)

{% for adjustment in cart.adjustments if adjustment.type == "Discount" %}
    {% set isCoupon = adjustment.optionsJson.code ? true : false %} 
        {{ adjustment.description }}
        ...etc

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.