<!-- Snippet plus_cart_discount_code --> 
{% if plus_cart_discount_code %} 
<script> 
(function($) { 
  $(document).on('page:load page:change', function () {
    if (localStorage.getItem('storedDiscount')){  
      var discountStored = localStorage.getItem('storedDiscount');   
      $('input[name="discount"]').val(localStorage.getItem('storedDiscount'));  
    }  
    $('form[action="/cart"]').on('submit', function(){
      var $discountCode = $('input[name="discount"]').val(); 
      localStorage.setItem('storedDiscount', $discountCode);  
    }); 
    
    $('.discount_code_save_button').on('click', function(){
      var $code =  $(this).prev("input").val();
      $('input[name="discount"]').val($code).change();
    });
  });   
})(jQuery);   
</script>
<div class="discountcodefield">
  <input style="display:none;" autocomplete="off" type="text" name="discount" />
  <div class="discount_box_custom">
    <div class="discount_box_inside">
      <input type="text">
      <div class="discount_code_save_button">Save</div>
      <p>Note: If your entered code is valid then discount will calculate on checkout page.</p>
    </div>
  </div>
</div>
{% endif %}