Applying discount codes in the cart (prior to checkout)

Create a new code snippet with cart-apply-discount

{% comment %}
  Replace the text below with the handle of your add-on product.
{% endcomment %}

{% assign product = all_products['put-your-product-handle-here'] %}

{% unless cart.item_count == 0 or product.empty? or product.variants.first.available == false %}

  {% assign variant_id = product.variants.first.id %}

  

{% endunless %}

Include the new snippet in your cart.liquid template

{% include 'cart-discount' %}
1 Like