Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add collection_point_name field to order confirmation webhook (#8268)
Paweł Kucharskideabfa4f1938
diff --git a/saleor/order/notifications.py b/saleor/order/notifications.pyindex 70ff39641a..8b3d382dd9 100644--- a/saleor/order/notifications.py+++ b/saleor/order/notifications.py@@ -244,6 +244,7 @@ def get_default_order_payload(order: "Order", redirect_url: str = ""):"billing_address": get_address_payload(order.billing_address),"shipping_address": get_address_payload(order.shipping_address),"shipping_method_name": order.shipping_method_name,+ "collection_point_name": order.collection_point_name,**get_discounts_payload(order),})diff --git a/saleor/order/tests/test_notifications.py b/saleor/order/tests/test_notifications.pyindex 5a6369eab9..24e5f052df 100644--- a/saleor/order/tests/test_notifications.py+++ b/saleor/order/tests/test_notifications.py@@ -74,6 +74,7 @@ def test_get_custom_order_payload(order):"phone": "+48713988102",},"shipping_method_name": None,+ "collection_point_name": None,"voucher_discount": None,"discounts": [],"discount_amount": 0,@@ -234,6 +235,7 @@ def test_get_default_order_payload(order_line):"total_gross_amount": order.total_gross_amount,"total_net_amount": order.total_net_amount,"shipping_method_name": order.shipping_method_name,+ "collection_point_name": order.collection_point_name,"status": order.status,"metadata": order.metadata,"private_metadata": order.private_metadata,@@ -337,6 +339,31 @@ def test_send_email_order_confirmation(mocked_notify, order, site_settings):)[email protected]("saleor.plugins.manager.PluginsManager.notify")+def test_send_email_order_confirmation_for_cc(+ mocked_notify, order_with_lines_for_cc, site_settings, warehouse_for_cc+):+ manager = get_plugins_manager()+ redirect_url = "https://www.example.com"++ notifications.send_order_confirmation(+ order_with_lines_for_cc, redirect_url, manager+ )++ expected_payload = {+ "order": get_default_order_payload(order_with_lines_for_cc, redirect_url),+ "recipient_email": order_with_lines_for_cc.get_customer_email(),+ "site_name": "mirumee.com",+ "domain": "mirumee.com",+ }+ mocked_notify.assert_called_once_with(+ NotifyEventType.ORDER_CONFIRMATION,+ expected_payload,+ channel_slug=order_with_lines_for_cc.channel.slug,+ )+ assert expected_payload["order"]["collection_point_name"] == warehouse_for_cc.name++@mock.patch("saleor.plugins.manager.PluginsManager.notify")def test_send_confirmation_emails_without_addresses_for_payment(mocked_notify,diff --git a/saleor/tests/fixtures.py b/saleor/tests/fixtures.pyindex d1e66ba864..3394a8cdd1 100644--- a/saleor/tests/fixtures.py+++ b/saleor/tests/fixtures.py@@ -3172,6 +3172,7 @@ def order_with_lines_for_cc()order.collection_point = warehouse_for_cc+ order.collection_point_name = warehouse_for_cc.nameorder.save()recalculate_order(order)diff --git a/saleor/webhook/payloads.py b/saleor/webhook/payloads.pyindex 8951592262..b538b20b01 100644--- a/saleor/webhook/payloads.py+++ b/saleor/webhook/payloads.py@@ -66,6 +66,7 @@ ORDER_FIELDS = ("origin","user_email","shipping_method_name",+ "collection_point_name","shipping_price_net_amount","shipping_price_gross_amount","shipping_tax_rate",diff --git a/saleor/webhook/tests/test_webhook_payloads.py b/saleor/webhook/tests/test_webhook_payloads.pyindex 0941ce771a..38d6ce1a67 100644--- a/saleor/webhook/tests/test_webhook_payloads.py+++ b/saleor/webhook/tests/test_webhook_payloads.py@@ -76,9 +76,12 @@ def test_generate_order_payload(payload = json.loads(generate_order_payload(order_with_lines))[0]assert order_id == payload["id"]- for field in ORDER_FIELDS:+ non_empty_fields = [f for f in ORDER_FIELDS if f != "collection_point_name"]+ for field in non_empty_fields:assert payload.get(field) is not None+ assert payload["collection_point_name"] is None+assert payload.get("shipping_method")assert payload.get("shipping_tax_rate")assert payload.get("lines")@@ -465,6 +468,7 @@ def test_generate_invoice_payload(fulfilled_order):"origin": OrderOrigin.CHECKOUT,"user_email": "[email protected]","shipping_method_name": "DHL",+ "collection_point_name": None,"shipping_price_net_amount": "10.000","shipping_price_gross_amount": "12.300","shipping_tax_rate": "0.0000",