Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Support fulfill 0 products only if total quantity is larger than 0 in API

Unknown13dde9157c10
diff --git a/saleor/graphql/order/mutations/fulfillments.py b/saleor/graphql/order/mutations/fulfillments.py
index 31eabb5505..d7a3042465 100644
--- a/saleor/graphql/order/mutations/fulfillments.py
+++ b/saleor/graphql/order/mutations/fulfillments.py
@@ -69,11 +69,7 @@ class FulfillmentCreate(BaseMutation):
@classmethod
def clean_lines(cls, order_lines, quantities, errors):
for order_line, quantity in zip(order_lines, quantities):
- if quantity <= 0:
- cls.add_error(
- errors, order_line,
- 'Quantity must be larger than 0.')
- elif quantity > order_line.quantity_unfulfilled:
+ if quantity > order_line.quantity_unfulfilled:
msg = npgettext_lazy(
'Fulfill order line mutation error',
'Only %(quantity)d item remaining to fulfill.',
@@ -93,6 +89,12 @@ class FulfillmentCreate(BaseMutation):
lines_ids, errors, 'lines', OrderLine)
cls.clean_lines(order_lines, quantities, errors)
+
+ if sum(quantities) <= 0:
+ cls.add_error(
+ errors, order_lines,
+ 'Total quantities must be larger than 0.')
+
if errors:
return cls(errors=errors)
input['order_lines'] = order_lines