Abandoned cart email - offer discount only if cart item is....

Hi,

How can I use liquid to include a discount code only if the item(s) in the cart is from a certain collection and not show that discount code if the cart contains items from this other collection?

Am I close if I do something like this:

{% if line.product.title != ‘this product that is not applicable for a discount’ or ‘this other product that can’t get the discount’%}

P.S. Here is a 15% discount good for 72 hours with coupon code: ComeBack15

{% endif %}

Thank you in advance,

-silver

Hello,

The simplest way would be to start the discount as true, then check if he product is in the non discount group. End the loop on the first instance, and give no discount.

If you’d like mygroup to code this, message send me a message.

Hi @silversorensen ,

You can refer to the code:

{%- assign check = false -%}

{%- for collection in line.product.collections -%}

{%- if collection.title == ‘Name collection’ -%}

{%- assign check = true -%}

{%- break -%}

{%- endif -%}

{%- endfor -%}

{%- if check == true -%}

P.S. Here is a 15% discount good for 72 hours with coupon code: ComeBack15

{%- endif -%}

  • With Name collection: Is the name of the collection, you can also change it to handle.

It will work when there is a product from the collection you want to display in the cart.

If you want all products to be in the collection and just one product is not in the collection, it won’t show, you should use this code:

{%- assign check = 0 -%}

{%- for collection in line.product.collections -%}

{%- if collection.title == ‘Name collection’ -%}

{%- assign check = check | plus: 1 -%}

{%- break -%}

{%- endif -%}

{%- endfor -%}

{%- if check == cart.item_count -%}

P.S. Here is a 15% discount good for 72 hours with coupon code: ComeBack15

{%- endif -%}

Hope it clear to you.

Hi there,

Thank you so much for taking the time to reply to this. However, it is not working as far as I can tell… I tried both scenarios and the discount code is not showing up when it should.

Any other thoughts on this?

Thank you,

-silver