fix(dashboard): allow creating fulfillment for items without shipping profile (#11733)

* fix: allow creating fulfillment of items without shipping profile

* fix: move quantity filtering
This commit is contained in:
Frane Polić
2025-03-09 13:48:41 +01:00
committed by GitHub
parent 70eaaa9196
commit bd4428c40e
@@ -111,30 +111,28 @@ export function OrderCreateFulfillmentForm({
return return
} }
const selectedShippingProfileId = let items = Object.entries(data.quantity)
selectedShippingOption?.shipping_profile_id
const itemShippingProfileMap = order.items.reduce(
(acc, item) => {
acc[item.id] = item.variant?.product?.shipping_profile?.id
return acc
},
{} as Record<string, string | null>
)
const items = Object.entries(data.quantity)
.filter(
([id, value]) =>
!!value && itemShippingProfileMap[id] === selectedShippingProfileId
)
.map(([id, quantity]) => ({ .map(([id, quantity]) => ({
id, id,
quantity, quantity,
})) }))
.filter(({ quantity }) => !!quantity)
if (!items.length) { /**
toast.error(t("orders.fulfillment.error.noItems")) * If items require shipping fulfill only items with matching shipping profile.
return */
if (requiresShipping) {
const selectedShippingProfileId =
selectedShippingOption?.shipping_profile_id
const itemShippingProfileMap = order.items.reduce((acc, item) => {
acc[item.id] = item.variant?.product?.shipping_profile?.id
return acc
}, {} as any)
items = items.filter(
({ id }) => itemShippingProfileMap[id] === selectedShippingProfileId
)
} }
const payload: HttpTypes.AdminCreateOrderFulfillment = { const payload: HttpTypes.AdminCreateOrderFulfillment = {
@@ -357,7 +355,9 @@ export function OrderCreateFulfillmentForm({
form={form} form={form}
item={item} item={item}
locationId={selectedLocationId} locationId={selectedLocationId}
disabled={!isShippingProfileMatching} disabled={
requiresShipping && !isShippingProfileMatching
}
itemReservedQuantitiesMap={ itemReservedQuantitiesMap={
itemReservedQuantitiesMap itemReservedQuantitiesMap
} }