Automatically Tag Orders with Image Swatch File Names in Giftship Product Options

Giftship offers a product option block called image swatch, allowing customers to select an image URL when adding items to their cart. If you wish to automatically tag an order with the file name of the selected image, you can utilize the following liquid code to tag the order accordingly.

How it Works:

Giftship offers a product option block called image swatch, allowing customers to select an image URL when adding items to their cart. If you wish to automatically tag an order with the file name of the selected image, you can utilize the following liquid code to tag the order accordingly.

Prerequisites:

  1. Auto Tag events: order created or updated during testing.
  2. Conditions: when lite items property name equals “gallery”.
  3. Tag order: with the liquid code provided below.

Tag Order With:

{% for line_item in order.line_items %}
    {% for property in line_item.properties %}
        {% if property.first == "gallery" %}
            {% assign url = property.last %}
            {% assign parts = url | split: "/" %}
            {% assign filename_with_query = parts | last | split: "?" | first %}
            {% assign filename_parts = filename_with_query | split: "." %}
            {% assign filename_without_extension = filename_parts[0] %}
            {{ filename_without_extension }}
        {% endif %}
    {% endfor %}
{% endfor %}

Conclusion

We recommend creating a test order to ensure your auto tag events fire upon update. Then, add a fake tag to the order and delete it. This will trigger Giftship’s auto tagger. Please thoroughly test before deploying live.

Can't find the answer in our documentation?
Contact Support