Skip to content

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

Cancel order if all quantities are changed to 0

Marcin Gębala61971a08c88e
diff --git a/saleor/order/models.py b/saleor/order/models.py
index 83a43d3d65..2c29ea942a 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -251,6 +251,9 @@ class OrderedItem(models.Model, ItemLine):
'product': self.product})
order.history.create(status=order.status, comment=comment, user=user)
+ if not any([item.quantity for item in order.get_items()]):
+ order.change_status('cancelled')
+
class Payment(BasePayment):