From 3ebd2a37bcd329b38825239c8bf1116eb7f85b57 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Thu, 19 Dec 2024 11:26:40 +0200 Subject: [PATCH] fix up order items fulfillment --- .../integrations/guides/shipstation/page.mdx | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/www/apps/resources/app/integrations/guides/shipstation/page.mdx b/www/apps/resources/app/integrations/guides/shipstation/page.mdx index dc6c8d0ec1a27..6c4fad9db8001 100644 --- a/www/apps/resources/app/integrations/guides/shipstation/page.mdx +++ b/www/apps/resources/app/integrations/guides/shipstation/page.mdx @@ -1007,10 +1007,11 @@ Finally, add the `createFulfillment` method in `ShipStationProviderService`: export const serviceHighlights6 = [ ["9", "shipment_id", "Retrieve the shipping method's shipment ID."], ["13", "originalShipment", "Retrieve the original shipment associated with the order's shipping method."], - ["16", "orderItemsToFulfill", "Get the order items to fulfill."], - ["21", "newShipment", "Create a new shipment for the fulfillment."], - ["44", "label", "Purchase a label for the new shipment."], - ["47", "data", "Store the ID of the label and its shipment in the fulfillment's data property."] + ["15", "orderItemsToFulfill", "Get the order items to fulfill."], + ["29", "quantity", "Set the quantity based on the quantity to be fulfilled."], + ["33", "newShipment", "Create a new shipment for the fulfillment."], + ["56", "label", "Purchase a label for the new shipment."], + ["59", "data", "Store the ID of the label and its shipment in the fulfillment's data property."] ] ```ts title="src/modules/shipstation/service.ts" highlights={serviceHighlights6} @@ -1028,10 +1029,22 @@ class ShipStationProviderService extends AbstractFulfillmentProviderService { const originalShipment = await this.client.getShipment(shipment_id) - // @ts-ignore - const orderItemsToFulfill = order.items.filter((item) => { + const orderItemsToFulfill = [] + + items.map((item) => { // @ts-ignore - return items.some((i) => i.line_item_id === item.id) + const orderItem = order.items.find((i) => i.id === item.line_item_id) + + if (!orderItem) { + return + } + + // @ts-ignore + orderItemsToFulfill.push({ + ...orderItem, + // @ts-ignore + quantity: item.quantity + }) }) const newShipment = await this.createShipment({