Skip to content

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

fix send order confirmation email to staff (#18343)

Shaokun-X66592d53ee98
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 04614f4462..b508b222f7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,4 +13,6 @@ All notable, unreleased changes to this project will be documented in this file.
### Other changes
- Improved page search with search vectors. Pages can now be searched by slug, title, content, attribute values, and page type information.
+- Fix send order confirmation email to staff - #18342 by @Shaokun-X
+
### Deprecations
diff --git a/saleor/order/notifications.py b/saleor/order/notifications.py
index 89f69fb244..09e0827f3b 100644
--- a/saleor/order/notifications.py
+++ b/saleor/order/notifications.py
@@ -455,7 +455,7 @@ def send_order_confirmation(order_info, redirect_url, manager):
}
return payload
- handler = NotifyHandler(_generate_payload)
+ handler = NotifyHandler(_generate_staff_payload)
manager.notify(
NotifyEventType.STAFF_ORDER_CONFIRMATION, payload_func=handler.payload
)
diff --git a/saleor/order/tests/test_notifications.py b/saleor/order/tests/test_notifications.py
index 0a5c52450a..8b23ee858e 100644
--- a/saleor/order/tests/test_notifications.py
+++ b/saleor/order/tests/test_notifications.py
@@ -429,6 +429,33 @@ def test_send_email_order_confirmation_for_cc(
assert expected_payload["order"]["collection_point_name"] == warehouse_for_cc.name
[email protected]("saleor.plugins.manager.PluginsManager.notify")
+def test_send_email_order_confirmation_with_staff_recipients(
+ mocked_notify, order, site_settings, staff_notification_recipient
+):
+ # given
+ manager = get_plugins_manager(allow_replica=False)
+ redirect_url = "https://www.example.com"
+ order_info = fetch_order_info(order)
+
+ # when
+ notifications.send_order_confirmation(order_info, redirect_url, manager)
+
+ # then
+ expected_payload = {
+ "order": get_default_order_payload(order, redirect_url),
+ "recipient_list": [staff_notification_recipient.get_email()],
+ **get_site_context_payload(site_settings.site),
+ }
+ assert mocked_notify.call_count == 2
+ call_args = mocked_notify.call_args_list[1]
+ called_args = call_args.args
+ called_kwargs = call_args.kwargs
+ assert called_args[0] == NotifyEventType.STAFF_ORDER_CONFIRMATION
+ assert len(called_kwargs) == 1
+ assert called_kwargs["payload_func"]() == expected_payload
+
+
@mock.patch("saleor.plugins.manager.PluginsManager.notify")
def test_send_confirmation_emails_without_addresses_for_payment(
mocked_notify,