I got this code off of Craft Commerce, I had caught an error on the site previously so I'm thinking there might be an error here? I've put it in my file but when I input anything in the form I don't have any response of any kind. I don't get an error message or success message, it just redirects back to the cart and the pricing also remains exactly the same. Thanks!

<form method="POST">
     <input type="hidden" name="action" value="commerce/cart/updateCart">
     <input type="hidden" name="redirect" value="store/cart">
     {{ getCsrfInput() }}
     <span class="{% if cart.getError('couponCode') %}has-error{% endif %}">
     <input type="text" name="couponCode" class="{% if cart.getError('couponCode') %}has-error{% endif %}" value="{{ cart.couponCode }}" placeholder="{{ "Coupon Code"|t }}">
     <input type="submit" value="{% if cart.couponCode %}Change{% else %}Apply{% endif %} Coupon"/>
  • What does cart.getErrors() return? Guessing there is a validation error on one of the other cart properties.
    – Brad Bell
    Oct 4, 2017 at 23:02
  • cart.getErrors() doesn't return anything, at least not in this code. Oct 5, 2017 at 12:50
  • Same issue here. How did you fix it? May 16, 2018 at 10:12

1 Answer 1


I had this problem and the cause was that I was doing this in the base template:

{% set cart = craft.commerce.carts.cart %}

When I should be doing the following:

{% if cart is not defined %}
    {% set cart = craft.commerce.carts.cart %}
{% endif %}

The reason behind is that the cart object in cart.getError function was always being initialized instead of getting the cart from the POST response.

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.