Adding a discount to the cart/checkout

Highlighted
New Member
1 0 0

Hi, I hope somebody can help me with this.  I am using the Minimal Theme and am trying to add a discount code in script.

So I am editing my "cart-template.liquid" and this bit works fine (line no. 7):

{% comment %}
  This is your /cart template.
{% endcomment %}
<div id="CartSection" data-section-id="{{ section.id }}" data-section-type="cart-template" data-notes-enable="{{ section.settings.cart_notes_enable }}">
  {% if cart.item_count > 0 %}
    <form action="/cart" method="post" novalidate class="cart">
      <input class="js-form-discount" type="hidden" name="discount" value="FREESHIPPING4U" >
      <div class="section-header">
        <h1 class="section-header__title">{{ 'cart.general.title' | t }}</h1>
      </div>

I would like to add the discount code if the shopper has more than 6 items in the cart using an "if" , like below but that doesn't work. (lines 7, 8 and 9.) I can't figure why it wouldn't/shouldn't:

{% comment %}
  This is your /cart template.
{% endcomment %}
<div id="CartSection" data-section-id="{{ section.id }}" data-section-type="cart-template" data-notes-enable="{{ section.settings.cart_notes_enable }}">
  {% if cart.item_count > 0 %}
    <form action="/cart" method="post" novalidate class="cart">
      {% if cart.item_count > 6 %}
         <input class="js-form-discount" type="hidden" name="discount" value="FREESHIPPING4U" >
      {% endif %}
      <div class="section-header">
        <h1 class="section-header__title">{{ 'cart.general.title' | t }}</h1>
      </div>

Any suggestions would be most appreciated.

 

Peter

 

0 Likes