Skip to content

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

Add docs for managing statuses

Anna Siwikca3d1e902cc6
diff --git a/docs/img/delivery_group_statuses.png b/docs/img/delivery_group_statuses.png
new file mode 100644
index 0000000000..379e818ac5
Binary files /dev/null and b/docs/img/delivery_group_statuses.png differ
diff --git a/docs/orders.rst b/docs/orders.rst
index ee65f46e6f..45d256c243 100644
--- a/docs/orders.rst
+++ b/docs/orders.rst
@@ -3,6 +3,7 @@ Order management
Orders are created after customers complete the checkout process. The `Order` object itself contains only general information about the customer's order.
+
Delivery Group
--------------
@@ -16,14 +17,31 @@ There are three possible delivery group statuses:
The default status of newly created delivery groups.
- ``SHIPPED``
- The delivery group has been marked as shipped.
+ The delivery group has been marked as shipped by a shop operator. Only ``NEW`` groups can be marked as shipped.
- ``CANCELLED``
- The delivery group has been cancelled.
+ The delivery group has been cancelled by a shop operator. Both ``NEW`` and ``SHIPPED`` groups can be marked as cancelled.
+
+
+Delivery Group statuses flow
+----------------------------
+
+.. image:: img/delivery_group_statuses.png
+
+Regular flow of statuses is from ``NEW`` to ``SHIPPED``. For managing states saleor uses `django_fsm <https://github.com/kmmbvnr/django-fsm>`_ package. Actions performed within changing status are placed in Delivery Group model and are as follows:
+
+- ``process(cart_lines, discounts=None)``
+ Adds specified cart lines to a group with optionally charged discounts and allocates quantity in corresponding stocks. Performed during creating order in checkout process.
+
+- ``ship()``
+ Decreases quantity in corresponding stocks. Performed just after shop operator marks group as shipped.
+
+- ``cancel()``
+ Deallocates or increases quantity in corresponding stocks, depending whether ``NEW`` or ``SHIPPED`` group is cancelled respectively. Performed just after shop operator marks group as cancelled.
Order statuses
---------
+--------------
Order status is deduced based on statuses of its delivery groups. There are two possible statuses: