Answers.Body: <p>I had this problem and the cause was that I was doing this in the base template:</p>
  
  <pre><code>{% set cart = craft.commerce.carts.cart %}
  </code></pre>
  
  <p>When I should be doing the following:</p>
  
  <pre><code>{% if cart is not defined %}
      {% set cart = craft.commerce.carts.cart %}
  {% endif %}
  </code></pre>
  
  <p>The reason behind is that the <code>cart</code> object in <code>cart.getError</code> function was always being initialized instead of getting the <code>cart</code> from the POST response.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-16T11:21:11.860Z
Answers.LastActivityDate: 2018-05-16T11:21:11.860Z
Answers.UserDisplayName: Rosana Ruiz
Body: <p>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!</p>
  
  <pre><code>&lt;form method="POST"&gt;
       &lt;input type="hidden" name="action" value="commerce/cart/updateCart"&gt;
       &lt;input type="hidden" name="redirect" value="store/cart"&gt;
       {{ getCsrfInput() }}
       &lt;span class="{% if cart.getError('couponCode') %}has-error{% endif %}"&gt;
       &lt;input type="text" name="couponCode" class="{% if cart.getError('couponCode') %}has-error{% endif %}" value="{{ cart.couponCode }}" placeholder="{{ "Coupon Code"|t }}"&gt;
       &lt;/span&gt;
       &lt;input type="submit" value="{% if cart.couponCode %}Change{% else %}Apply{% endif %} Coupon"/&gt;
  &lt;/form&gt;
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-04T23:02:59.423Z
Comments.Text: What does `cart.getErrors()` return?  Guessing there is a validation error on one of the other cart properties.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-05T12:50:36.987Z
Comments.Text: `cart.getErrors()` doesn't return anything, at least not in this code.
Comments.UserDisplayName: Darryl Hardin
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-16T10:12:31.193Z
Comments.Text: Same issue here. How did you fix it?
Comments.UserDisplayName: Rosana Ruiz
Tags: <plugin-craftcommerce>
Title: Using the coupon code from Craft Commerce site
ThreadText: # Using the coupon code from Craft Commerce site
  
  (Asked by: username_0 on 2017-10-04)
  
  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 }}">
       </span>
       <input type="submit" value="{% if cart.couponCode %}Change{% else %}Apply{% endif %} Coupon"/>
  </form>
  
  ```
  
  **Tags:** plugin-craftcommerce
  
  > **Comments:**
  > **username_1**: What does `cart.getErrors()` return?  Guessing there is a validation error on one of the other cart properties.  
  > **username_0**: `cart.getErrors()` doesn't return anything, at least not in this code.  
  > **username_2**: Same issue here. How did you fix it?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-05-16. Score: 2 | Accepted answer
  
  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.
  
  
  ---
  
  