Add Order Tag Containing Item SKU if Item has certain tag.

Hi all,

What the title says. The use case is to tag the order with something like “FinalSale:SKU” so that our staff does not have to check each item individually on a given order to find out that an item on it is final sale.

For example if the order contains two products, SKU1 and SKU2 and SKU1 is tagged with “final sale”, I would like to add a tag to the order that says FinalSale:SKU1

I’m able to tag the order with a generalized tag such as “FinalSale” if ANY item on the order is final sale, that’s simple enough, but ideally I’d like to include the SKU in the tag itself.

Thanks in advance.

1 Like

You probably need to set it up like:

  • Order created
  • for each (order / lineItems)
    • If lineItem / product / sku == SKU1
      • Add product tag (with the specific line item.product.sku in the tag as a variable)

I was able to figure this out. For anyone curious:

{% for lineItems_item in order.lineItems %} {% for tags_item in lineItems_item.product.tags %} {% if tags_item == "FinalSale" %}FinalSale:{{lineItems_item.sku}}{% endif %}{% endfor %},{% endfor %}

Hi James,

Could you please explain how and where do you add this code? I’m looking for something similar:

Yes, I ended up using order note because it’s more visible to staff when viewing an order. The logic should be the same.

Our tag is “no-returns” for the items we want to catch. The end result looks like the below.