Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Drop CHECKOUT_QUANTITY_CHANGED webhook (#6797)
Damian Wysocki66d263c8f7f9
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 30e0c9365f..e05aae2771 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,7 @@ All notable, unreleased changes to this project will be documented in this file.- Drop authorization keys API - #6631 by @maarcingebala- Drop `type` field from `AttributeValue` type - #6710 by @IKarbowiak- Drop `apply_taxes_to_shipping_price_range` plugin hook - #6746 by @maarcingebala+- Drop `CHECKOUT_QUANTITY_CHANGED` webhook - #6797 by @d-wysocki### Otherdiff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.pyindex 3710e02c24..8ecb01df31 100644--- a/saleor/graphql/checkout/mutations.py+++ b/saleor/graphql/checkout/mutations.py@@ -434,7 +434,6 @@ class CheckoutLinesAdd(BaseMutation):"Can't add unpublished product.",code=exc.code,)- info.context.plugins.checkout_quantity_changed(checkout)lines = fetch_checkout_lines(checkout)update_checkout_shipping_method_if_invalid(@@ -483,7 +482,6 @@ class CheckoutLineDelete(BaseMutation):if line and line in checkout.lines.all():line.delete()- info.context.plugins.checkout_quantity_changed(checkout)lines = fetch_checkout_lines(checkout)update_checkout_shipping_method_if_invalid(diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex a9ed44fb4d..ab38e932bf 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -5786,7 +5786,6 @@ enum WebhookEventTypeEnum {CUSTOMER_CREATEDPRODUCT_CREATEDPRODUCT_UPDATED- CHECKOUT_QUANTITY_CHANGEDCHECKOUT_CREATEDCHECKOUT_UPDATEDFULFILLMENT_CREATED@@ -5808,7 +5807,6 @@ enum WebhookSampleEventTypeEnum {CUSTOMER_CREATEDPRODUCT_CREATEDPRODUCT_UPDATED- CHECKOUT_QUANTITY_CHANGEDCHECKOUT_CREATEDCHECKOUT_UPDATEDFULFILLMENT_CREATEDdiff --git a/saleor/graphql/webhook/mutations.py b/saleor/graphql/webhook/mutations.pyindex 26d0a58e60..761c60a9d9 100644--- a/saleor/graphql/webhook/mutations.py+++ b/saleor/graphql/webhook/mutations.py@@ -14,10 +14,7 @@ class WebhookCreateInput(graphene.InputObjectType):target_url = graphene.String(description="The url to receive the payload.")events = graphene.List(WebhookEventTypeEnum,- description=(- "The events that webhook wants to subscribe. The CHECKOUT_QUANTITY_CHANGED"- " is deprecated. It will be removed in Saleor 3.0"- ),+ description=("The events that webhook wants to subscribe."),)app = graphene.ID(required=False,@@ -101,10 +98,7 @@ class WebhookUpdateInput(graphene.InputObjectType):)events = graphene.List(WebhookEventTypeEnum,- description=(- "The events that webhook wants to subscribe. The CHECKOUT_QUANTITY_CHANGED"- " is deprecated. It will be removed in Saleor 3.0"- ),+ description=("The events that webhook wants to subscribe."),required=False,)app = graphene.ID(diff --git a/saleor/graphql/webhook/tests/test_webhook.py b/saleor/graphql/webhook/tests/test_webhook.pyindex 2fbc84beb1..3a262a4d5b 100644--- a/saleor/graphql/webhook/tests/test_webhook.py+++ b/saleor/graphql/webhook/tests/test_webhook.py@@ -421,7 +421,6 @@ SAMPLE_PAYLOAD_QUERY = """(WebhookSampleEventTypeEnum.CUSTOMER_CREATED, False),(WebhookSampleEventTypeEnum.PRODUCT_CREATED, False),(WebhookSampleEventTypeEnum.PRODUCT_UPDATED, False),- (WebhookSampleEventTypeEnum.CHECKOUT_QUANTITY_CHANGED, False),(WebhookSampleEventTypeEnum.CHECKOUT_CREATED, False),(WebhookSampleEventTypeEnum.CHECKOUT_UPDATED, False),(WebhookSampleEventTypeEnum.FULFILLMENT_CREATED, True),@@ -465,7 +464,6 @@ def test_sample_payload_query_by_app((WebhookSampleEventTypeEnum.CUSTOMER_CREATED, True),(WebhookSampleEventTypeEnum.PRODUCT_CREATED, True),(WebhookSampleEventTypeEnum.PRODUCT_UPDATED, True),- (WebhookSampleEventTypeEnum.CHECKOUT_QUANTITY_CHANGED, True),(WebhookSampleEventTypeEnum.CHECKOUT_CREATED, True),(WebhookSampleEventTypeEnum.CHECKOUT_UPDATED, True),(WebhookSampleEventTypeEnum.FULFILLMENT_CREATED, False),diff --git a/saleor/plugins/base_plugin.py b/saleor/plugins/base_plugin.pyindex d4c613b57b..8a0c4788a6 100644--- a/saleor/plugins/base_plugin.py+++ b/saleor/plugins/base_plugin.py@@ -409,12 +409,6 @@ class BasePlugin:"""return NotImplemented- # Deprecated. This method will be removed in Saleor 3.0- def checkout_quantity_changed(- self, checkout: "Checkout", previous_value: Any- ) -> Any:- return NotImplemented-def checkout_created(self, checkout: "Checkout", previous_value: Any) -> Any:"""Trigger when checkout is created.diff --git a/saleor/plugins/manager.py b/saleor/plugins/manager.pyindex 8be0576fdf..52fd882c6f 100644--- a/saleor/plugins/manager.py+++ b/saleor/plugins/manager.py@@ -435,13 +435,6 @@ class PluginsManager(PaymentInterface):"fulfillment_created", default_value, fulfillment)- # Deprecated. This method will be removed in Saleor 3.0- def checkout_quantity_changed(self, checkout: "Checkout"):- default_value = None- return self.__run_method_on_plugins(- "checkout_quantity_changed", default_value, checkout- )-def checkout_created(self, checkout: "Checkout"):default_value = Nonereturn self.__run_method_on_plugins("checkout_created", default_value, checkout)diff --git a/saleor/plugins/webhook/plugin.py b/saleor/plugins/webhook/plugin.pyindex 3919ed152f..82326094ac 100644--- a/saleor/plugins/webhook/plugin.py+++ b/saleor/plugins/webhook/plugin.py@@ -121,17 +121,6 @@ class WebhookPlugin(BasePlugin):product_data = generate_product_payload(product)trigger_webhooks_for_event.delay(WebhookEventType.PRODUCT_UPDATED, product_data)- # Deprecated. This method will be removed in Saleor 3.0- def checkout_quantity_changed(- self, checkout: "Checkout", previous_value: Any- ) -> Any:- if not self.active:- return previous_value- checkout_data = generate_checkout_payload(checkout)- trigger_webhooks_for_event.delay(- WebhookEventType.CHECKOUT_QUANTITY_CHANGED, checkout_data- )-def checkout_created(self, checkout: "Checkout", previous_value: Any) -> Any:if not self.active:return previous_valuediff --git a/saleor/plugins/webhook/tests/test_webhook.py b/saleor/plugins/webhook/tests/test_webhook.pyindex ffa97aad94..9ed150cb5f 100644--- a/saleor/plugins/webhook/tests/test_webhook.py+++ b/saleor/plugins/webhook/tests/test_webhook.py@@ -172,20 +172,6 @@ def test_order_cancelled(mocked_webhook_trigger, settings, order_with_lines):)[email protected]("saleor.plugins.webhook.plugin.trigger_webhooks_for_event.delay")-def test_checkout_quantity_changed(- mocked_webhook_trigger, settings, checkout_with_items-):- settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]- manager = get_plugins_manager()- manager.checkout_quantity_changed(checkout_with_items)-- expected_data = generate_checkout_payload(checkout_with_items)- mocked_webhook_trigger.assert_called_once_with(- WebhookEventType.CHECKOUT_QUANTITY_CHANGED, expected_data- )--@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_for_event.delay")def test_checkout_created(mocked_webhook_trigger, settings, checkout_with_items):settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]diff --git a/saleor/webhook/event_types.py b/saleor/webhook/event_types.pyindex b35c1d5207..86e3c1bbf2 100644--- a/saleor/webhook/event_types.py+++ b/saleor/webhook/event_types.py@@ -27,9 +27,6 @@ class WebhookEventType:PRODUCT_CREATED = "product_created"PRODUCT_UPDATED = "product_updated"- # This event is deprecated. It will be removed in Saleor 3.0- CHECKOUT_QUANTITY_CHANGED = "checkout_quantity_changed"-CHECKOUT_CREATED = "checkout_created"CHECKOUT_UPADTED = "checkout_updated"@@ -51,8 +48,6 @@ class WebhookEventType:CUSTOMER_CREATED: "Customer created",PRODUCT_CREATED: "Product created",PRODUCT_UPDATED: "Product updated",- # CHECKOUT_QUANTITY_CHANGED is deprecated. It will be removed in Saleor 3.0- CHECKOUT_QUANTITY_CHANGED: "Checkout quantity changed",CHECKOUT_CREATED: "Checkout created",CHECKOUT_UPADTED: "Checkout updated",FULFILLMENT_CREATED: "Fulfillment_created",@@ -75,8 +70,6 @@ class WebhookEventType:(CUSTOMER_CREATED, DISPLAY_LABELS[CUSTOMER_CREATED]),(PRODUCT_CREATED, DISPLAY_LABELS[PRODUCT_CREATED]),(PRODUCT_UPDATED, DISPLAY_LABELS[PRODUCT_UPDATED]),- # CHECKOUT_QUANTITY_CHANGED is deprecated. It will be removed in Saleor 3.0- (CHECKOUT_QUANTITY_CHANGED, DISPLAY_LABELS[CHECKOUT_QUANTITY_CHANGED]),(CHECKOUT_CREATED, DISPLAY_LABELS[CHECKOUT_CREATED]),(CHECKOUT_UPADTED, DISPLAY_LABELS[CHECKOUT_UPADTED]),(FULFILLMENT_CREATED, DISPLAY_LABELS[FULFILLMENT_CREATED]),@@ -98,7 +91,6 @@ class WebhookEventType:CUSTOMER_CREATED: AccountPermissions.MANAGE_USERS,PRODUCT_CREATED: ProductPermissions.MANAGE_PRODUCTS,PRODUCT_UPDATED: ProductPermissions.MANAGE_PRODUCTS,- CHECKOUT_QUANTITY_CHANGED: CheckoutPermissions.MANAGE_CHECKOUTS,CHECKOUT_CREATED: CheckoutPermissions.MANAGE_CHECKOUTS,CHECKOUT_UPADTED: CheckoutPermissions.MANAGE_CHECKOUTS,FULFILLMENT_CREATED: OrderPermissions.MANAGE_ORDERS,diff --git a/saleor/webhook/payloads.py b/saleor/webhook/payloads.pyindex c65a56cfc1..2c772ad578 100644--- a/saleor/webhook/payloads.py+++ b/saleor/webhook/payloads.py@@ -345,7 +345,6 @@ def _generate_sample_order_payload(event_name):def generate_sample_payload(event_name: str) -> Optional[dict]:checkout_events = [- WebhookEventType.CHECKOUT_QUANTITY_CHANGED,WebhookEventType.CHECKOUT_UPADTED,WebhookEventType.CHECKOUT_CREATED,]diff --git a/saleor/webhook/tests/test_webhook_sample_payloads.py b/saleor/webhook/tests/test_webhook_sample_payloads.pyindex 6e3ff32d18..cad313b236 100644--- a/saleor/webhook/tests/test_webhook_sample_payloads.py+++ b/saleor/webhook/tests/test_webhook_sample_payloads.py@@ -148,7 +148,7 @@ def _remove_anonymized_checkout_data(checkout_data: dict) -> dict:def test_generate_sample_checkout_payload(user_checkout_with_items):checkout = user_checkout_with_items- payload = generate_sample_payload(WebhookEventType.CHECKOUT_QUANTITY_CHANGED)+ payload = generate_sample_payload(WebhookEventType.CHECKOUT_UPADTED)checkout_payload = json.loads(generate_checkout_payload(checkout))# Check anonymized data differassert checkout.token != payload[0]["token"]