Skip to content

Commit bd4428c

Browse files
authored
fix(dashboard): allow creating fulfillment for items without shipping profile (medusajs#11733)
* fix: allow creating fulfillment of items without shipping profile * fix: move quantity filtering
1 parent 70eaaa9 commit bd4428c

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

packages/admin/dashboard/src/routes/orders/order-create-fulfillment/components/order-create-fulfillment-form/order-create-fulfillment-form.tsx

+20-20
Original file line numberDiff line numberDiff line change
@@ -111,30 +111,28 @@ export function OrderCreateFulfillmentForm({
111111
return
112112
}
113113

114-
const selectedShippingProfileId =
115-
selectedShippingOption?.shipping_profile_id
116-
117-
const itemShippingProfileMap = order.items.reduce(
118-
(acc, item) => {
119-
acc[item.id] = item.variant?.product?.shipping_profile?.id
120-
return acc
121-
},
122-
{} as Record<string, string | null>
123-
)
124-
125-
const items = Object.entries(data.quantity)
126-
.filter(
127-
([id, value]) =>
128-
!!value && itemShippingProfileMap[id] === selectedShippingProfileId
129-
)
114+
let items = Object.entries(data.quantity)
130115
.map(([id, quantity]) => ({
131116
id,
132117
quantity,
133118
}))
119+
.filter(({ quantity }) => !!quantity)
134120

135-
if (!items.length) {
136-
toast.error(t("orders.fulfillment.error.noItems"))
137-
return
121+
/**
122+
* If items require shipping fulfill only items with matching shipping profile.
123+
*/
124+
if (requiresShipping) {
125+
const selectedShippingProfileId =
126+
selectedShippingOption?.shipping_profile_id
127+
128+
const itemShippingProfileMap = order.items.reduce((acc, item) => {
129+
acc[item.id] = item.variant?.product?.shipping_profile?.id
130+
return acc
131+
}, {} as any)
132+
133+
items = items.filter(
134+
({ id }) => itemShippingProfileMap[id] === selectedShippingProfileId
135+
)
138136
}
139137

140138
const payload: HttpTypes.AdminCreateOrderFulfillment = {
@@ -357,7 +355,9 @@ export function OrderCreateFulfillmentForm({
357355
form={form}
358356
item={item}
359357
locationId={selectedLocationId}
360-
disabled={!isShippingProfileMatching}
358+
disabled={
359+
requiresShipping && !isShippingProfileMatching
360+
}
361361
itemReservedQuantitiesMap={
362362
itemReservedQuantitiesMap
363363
}

0 commit comments

Comments
 (0)