Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@basilkhan05
Last active January 4, 2022 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save basilkhan05/ecd2bdaa9cccd682af2a369e6a92fe27 to your computer and use it in GitHub Desktop.
Save basilkhan05/ecd2bdaa9cccd682af2a369e6a92fe27 to your computer and use it in GitHub Desktop.
Merging line items with the same SKU for bundles in Shopify order packing slips
{% assign unique_line_item_skus = line_items_in_shipment | map: 'sku' | uniq %}
{% for line_item_sku in unique_line_item_skus %}
{% assign total_quantity = 0 %}
{% assign total_shipping_quantity = 0 %}
{% assign sku_line_items = line_items_in_shipment | where: "sku", line_item_sku %}
{% for line_item in sku_line_items %}
{% assign total_quantity = total_quantity | plus: line_item.quantity %}
{% assign total_shipping_quantity = total_shipping_quantity | plus: line_item.shipping_quantity %}
{% endfor %}
{% assign line_item = sku_line_items | first %}
<!-- Keep the existing template intact in the for loop intact -->
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment