As the title suggests, I’m trying to get an if/else logic to work and have tried many different ways. The snippet below has been the most “successful” in terms of actually getting an output:
{% if line_item.product.collections == ‘FOOD’ %}
{% assign group = “FOOD” %}
{% else %}
{% assign group = “OTHER” %}
{% endif %}
and also tried:
{% if line_item.product.collections contains “FOOD” %}
{% assign group = “FOOD” %}
{% else %}
{% assign group = “OTHER” %}
{% endif %}
However, with both snippets I only see “OTHER” even though I purchased an item that is in a collection named FOOD.
I hope this is clear but I’m happy to elaborate if/where necessary.
Unfortunately, no luck. I am trying this in the Checkout>>Additional Scripts box.
From research, I’ve seen that collection variables do not work at checkout meaning that although the scripts we’re trying are correct, it’s not accepted at checkout.