Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Copy checkout meta to new orders on completion
Dan Kolbman3f97960345e4
diff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.pyindex 012e7966ac..6dcf0808ee 100644--- a/saleor/checkout/utils.py+++ b/saleor/checkout/utils.py@@ -754,6 +754,11 @@ def create_order(# assign checkout payments to the ordercheckout.payments.update(order=order)+ # copy metadata from the checkout into the new order+ order.meta = checkout.meta+ order.private_meta = checkout.private_meta+ order.save()+order_created(order=order, user=user)# Send the order confirmation emaildiff --git a/tests/api/test_checkout.py b/tests/api/test_checkout.pyindex 9b6bb60e05..bface0f5e6 100644--- a/tests/api/test_checkout.py+++ b/tests/api/test_checkout.py@@ -1162,6 +1162,10 @@ def test_checkout_complete(checkout.shipping_address = addresscheckout.shipping_method = shipping_methodcheckout.billing_address = address+ checkout.store_meta(namespace="PUBLIC", client="PLUGIN", item={"accepted": "true"})+ checkout.store_private_meta(+ namespace="PRIVATE", client="PLUGIN", item={"accepted": "true"},+ )checkout.save()checkout_line = checkout.lines.first()@@ -1193,6 +1197,8 @@ def test_checkout_complete(order = Order.objects.first()assert order.token == order_tokenassert order.total.gross == total.gross - gift_current_balance+ assert order.meta == checkout.meta+ assert order.private_meta == checkout.private_metaorder_line = order.lines.first()assert checkout_line_quantity == order_line.quantity