Save Pickup Location as a tag

Hi,

I’m trying to add the pickup location as a tag but it does not work right now. I’m doing this

{%- assign pickup_location = “” -%} {%- for li in order.lineItems -%} {%- if pickup_location == “” and li.fulfillmentService.location.name != blank -%} {%- assign pickup_location = li.fulfillmentService.location.name -%} {%- endif -%} {%- endfor -%} {{ pickup_location }}

But it is always adding the first location even though it’s not the one selected for this order.

Can someone help ?

Thanks

First, I typically test code like this in “log output” so I don’t mess up my shop data and I can see the variables.

A fulfillment service on a lineItem is one that stocks that particular product but not the one used for the order. Also this is deprecated, so I don’t recommend using it at all.

If you want to know which location it was assigned to be fulfilled from, that info is on: order / fulfillment orders / assigned location

Note that fulfillment orders are assigned after an order is created, so you cannot use “order created” as the trigger (reliably, unless you add a wait step after it of ~ 10 min). Better to use “fulfillment order ready to fulfill”.