Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
add Checkout.customer_note field to Checkout type (#16561)
Artura812d51dd1ac
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8ae83a05f1..5db477ad9a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,6 +14,7 @@ All notable, unreleased changes to this project will be documented in this file.### GraphQL API- Add `CheckoutCustomerNoteUpdate` mutation - #16315 by @pitkes22+- Add `customerNote` field to `Checkout` type to make it consistent with `Order` model - #16561 by @Air-t### Webhooksdiff --git a/saleor/graphql/checkout/mutations/checkout_customer_note_update.py b/saleor/graphql/checkout/mutations/checkout_customer_note_update.pyindex 0c8d14f528..d16d9572ec 100644--- a/saleor/graphql/checkout/mutations/checkout_customer_note_update.py+++ b/saleor/graphql/checkout/mutations/checkout_customer_note_update.py@@ -49,7 +49,6 @@ class CheckoutCustomerNoteUpdate(BaseMutation):id=None,):checkout = cls.get_node_or_error(info, id, only_type=Checkout)-checkout.note = customer_notecls.clean_instance(info, checkout)checkout.save(update_fields=["note", "last_change"])diff --git a/saleor/graphql/checkout/tests/mutations/test_checkout_customer_note_update.py b/saleor/graphql/checkout/tests/mutations/test_checkout_customer_note_update.pyindex 1c7f125881..3680ff023d 100644--- a/saleor/graphql/checkout/tests/mutations/test_checkout_customer_note_update.py+++ b/saleor/graphql/checkout/tests/mutations/test_checkout_customer_note_update.py@@ -15,6 +15,7 @@ CHECKOUT_CUSTOMER_NOTE_UPDATE_MUTATION = """checkout {id,note+ customerNote},errors {field,@@ -51,6 +52,7 @@ def test_checkout_customer_note_update(user_api_client, checkout_with_item):assert not data["errors"]checkout.refresh_from_db()assert checkout.note == customer_note+ assert data["checkout"]["customerNote"] == data["checkout"]["note"] == customer_noteassert checkout.last_change != previous_last_changediff --git a/saleor/graphql/checkout/types.py b/saleor/graphql/checkout/types.pyindex 069839e94a..c2346be628 100644--- a/saleor/graphql/checkout/types.py+++ b/saleor/graphql/checkout/types.py@@ -50,6 +50,7 @@ from ..core.descriptions import (ADDED_IN_315,ADDED_IN_318,ADDED_IN_319,+ ADDED_IN_321,DEPRECATED_IN_3X_FIELD,PREVIEW_FEATURE,)@@ -531,7 +532,14 @@ class Checkout(ModelObjectType[models.Checkout]):"saleor.graphql.account.types.Address",description="The shipping address of the checkout.",)- note = graphene.String(required=True, description="The note for the checkout.")+ customer_note = graphene.String(+ required=True, description=f"The customer note for the checkout. {ADDED_IN_321}"+ )+ note = graphene.String(+ required=True,+ description="The note for the checkout.",+ deprecation_reason=f"{DEPRECATED_IN_3X_FIELD} Use `customerNote` instead.",+ )discount = graphene.Field(Money,description=(@@ -816,6 +824,10 @@ class Checkout(ModelObjectType[models.Checkout]):model = models.Checkoutinterfaces = [graphene.relay.Node, ObjectWithMetadata]+ @staticmethod+ def resolve_customer_note(root: models.Checkout, _info: ResolveInfo):+ return root.note+@staticmethoddef resolve_created(root: models.Checkout, _info: ResolveInfo):return root.created_atdiff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex baf95cb8c7..c20f2904d0 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -10943,8 +10943,15 @@ type Checkout implements Node & ObjectWithMetadata @doc(category: "Checkout") {"""The shipping address of the checkout."""shippingAddress: Address+ """+ The customer note for the checkout.++ Added in Saleor 3.21.+ """+ customerNote: String!+"""The note for the checkout."""- note: String!+ note: String! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `customerNote` instead.")"""The total discount applied to the checkout. Note: Only discount created via voucher are included in this field.