How can I tell how many build kits shipped using the API?

Hi! We use build kits, and our integration needs to report shipments back to our store by the kit SKU, since the components aren’t on the customer’s order. The problem is that shipments only list the components. The parent kit line shows quantity_shipped 0, as if it never shipped.

ShipHero syncs these to Shopify correctly, so it must be tracking the kit somewhere. Is there a field that gives us the kit quantity shipped? Or do we really have to check the bill of materials and work it out from the components?

Hi! There’s no field with the kit quantity shipped. ShipHero doesn’t store one either: when it syncs to Shopify, it works it out from the components that shipped. You can do the same, and you don’t need the bill of materials, because each component line tells you which kit line it came from.

When an order has a build kit:

  • The kit line stays on the order with its original quantity and partner_line_item_id. Its fulfillment_status changes to broken_in_sets, and quantity_shipped stays at 0.
  • ShipHero adds one line per component, with price 0. Its partner_line_item_id is the kit line’s id plus a suffix: --.

To get the kits shipped:

  1. For each shipment line item, read line_item { partner_line_item_id sku } and the quantity shipped.
  2. If the partner_line_item_id ends in --, it’s a component. Remove that suffix from the right and you have the kit line’s partner_line_item_id.
  3. Kits shipped = ceil(component quantity shipped x kit line quantity / component line quantity). Take both quantities from the order’s line_items, not from the product’s current kit setup, since later kit changes don’t affect existing orders.
  4. If a kit ships partially across shipments, its components can give different results. ShipHero rounds up and caps at the kit’s ordered quantity. If you only want to count complete kits, use the lowest result across that kit’s components.