Glitches in Flow email including line items and quantity from only one fulfillment order

I have two locations which can ship the same items. I use location-2 as an overflow if location-1 can’t ship the total quantity of a product, in those cases I might ship what I can from location-1 and mark fulfilled to trigger sending of this email to location-2 to ship the remaining quantity.

The Flow is setup like this:

  1. Start when… Order fulfilled
  2. Check if… fulfillment.requiresShipping AND fulfillment.location.name does NOT include location-1
  3. Then… send the following internal email (which is intended to include only items fulfilled while assigned to location-2)

Problem 1: I recently noticed that the table included the total quantity of a line item ordered instead of only the quantity assigned to location-2. I.e. the order has qty-5 of shirt; location-1 ships 3; the remaining two are moved to location-2; this email should then request location-2 only send the two. However the email requested all 5 instead of only the two which were assigned to location-2. I’m not sure how to further contain the line quantity to only those in the specific fulfillment at hand versus the total number ordered on the parent order item?

Problem 2: I recently had a customer change items on his order. I edited the order, removing some items and adding others. However the table included ALL of the items, both currently active and removed by the edit. Is there some if-condition check I can add to fulfillmentOrders_item.lineItems to exclude items that are removed and not included in the fulfillment request?


    {%- for fulfillmentOrders_item in fulfillment.fulfillmentOrders -%}

    {% comment %} Sort rows by title {% endcomment %}

      {% assign lines_by_title = fulfillmentOrders_item.lineItems | sort: 'productTitle' %}

      {% for line in lines_by_title %}

          {%- assign line_quantity = line.lineItem.quantity | times: 1 -%}

          {% comment %} Running count of fulfillment total items {% endcomment %}
          {%- assign total_item_count = total_item_count | plus: line_quantity -%}

          

            {% comment %} Supplier-sku metafield instead of SKU {% endcomment %}

            

            {%- capture variant_line -%}
            {{ line.productTitle }}{%- if line.variantTitle -%}, {{ line.variantTitle }}{%- endif -%}
            {%- endcapture -%}
            

      {%- endfor -%}
    {%- endfor -%}
  

| {{ line_quantity }} | <br>              {% assign supplier_sku = line.lineItem.variant.metafields<br>                | where: 'namespace', 'inventory'<br>                | where: 'key', 'sku_supplier'<br>                | first<br>              -%}<br>              {{- supplier_sku.value }}<br>             | <br>              {{ variant_line }}<br>             |
| - | - | - |

In both of these, it’s not clear what you want to do, as the language isn’t precise enough. Can you refine?