Skip to content

Commit

Permalink
Add chennel data to order webhook (saleor#7299)
Browse files Browse the repository at this point in the history
* Add chennel data to order webhook

* Update changelog
  • Loading branch information
krzysztofwolski authored May 7, 2021
1 parent 8ed8f0c commit 25a1a18
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ All notable, unreleased changes to this project will be documented in this file.
- drop `created` argument from `draftOrders` query
- drop `productType` from `ProductFilter`
- deprecate mutations' `<name>Errors`, typed `errors` fields and remove deprecation
- Add channel data to Order webhook - #7299 by @krzysztofwolski

### Other

Expand Down
4 changes: 4 additions & 0 deletions saleor/webhook/payloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,16 @@ def generate_order_payload(order: "Order"):
"translated_name",
"reason",
)

channel_fields = ("slug", "currency_code")
shipping_method_fields = ("name", "type", "currency", "price_amount")

lines = order.lines.all()
order_data = serializer.serialize(
[order],
fields=ORDER_FIELDS,
additional_fields={
"channel": (lambda o: o.channel, channel_fields),
"shipping_method": (lambda o: o.shipping_method, shipping_method_fields),
"payments": (lambda o: o.payments.all(), payment_fields),
"shipping_address": (lambda o: o.shipping_address, ADDRESS_FIELDS),
Expand Down

0 comments on commit 25a1a18

Please sign in to comment.