Skip to content

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

Remove deprecated orderSettingsUpdate mutation (#19472)

Lukasz Ostrowski0438cf19a712
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1628926a35..4f7dcc5faf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,8 @@ All notable, unreleased changes to this project will be documented in this file.
- Bulk delete mutations now limit the number of `ids` per call (default 100, configurable via the `BULK_DELETE_LIMIT` env var). Exceeding the limit returns an `INVALID` error. This applies to all bulk delete mutations, including `productBulkDelete`, `productVariantBulkDelete`, `categoryBulkDelete`, `collectionBulkDelete`, `productTypeBulkDelete`, `productMediaBulkDelete`, `attributeBulkDelete`, `attributeValueBulkDelete`, `customerBulkDelete`, `staffBulkDelete`, `pageBulkDelete`, `pageTypeBulkDelete`, `menuBulkDelete`, `menuItemBulkDelete`, `giftCardBulkDelete`, `saleBulkDelete`, `voucherBulkDelete`, `promotionBulkDelete`, `shippingPriceBulkDelete`, `shippingZoneBulkDelete`, `draftOrderBulkDelete`, and `draftOrderLinesBulkDelete`.
- Removed the deprecated `checkoutId` input argument from the `checkoutShippingAddressUpdate` and `checkoutBillingAddressUpdate` mutations. Use the `id` argument instead.
- `confirmAccount()` mutation no longer allows to confirm an account that was already confirmed. - #19459 by @NyanKiyosi
+- Removed the deprecated `orderSettingsUpdate` mutation. Use the `channelUpdate` mutation with the `orderSettings` input to update order settings per channel instead.
+- Removed the deprecated `orderSettings` query field. Use the `channel` query and read its `orderSettings` field instead.
### GraphQL API
diff --git a/saleor/graphql/core/enums.py b/saleor/graphql/core/enums.py
index f05160e0c7..33ee17eb1e 100644
--- a/saleor/graphql/core/enums.py
+++ b/saleor/graphql/core/enums.py
@@ -263,11 +263,6 @@ MenuErrorCode: Final[graphene.Enum] = graphene.Enum.from_enum(
menu_error_codes.MenuErrorCode
)
-OrderSettingsErrorCode: Final[graphene.Enum] = graphene.Enum.from_enum(
- site_error_codes.OrderSettingsErrorCode
-)
-OrderSettingsErrorCode.doc_category = DOC_CATEGORY_ORDERS
-
GiftCardSettingsErrorCode: Final[graphene.Enum] = graphene.Enum.from_enum(
site_error_codes.GiftCardSettingsErrorCode
)
diff --git a/saleor/graphql/core/types/__init__.py b/saleor/graphql/core/types/__init__.py
index 88745e0dec..47bef52738 100644
--- a/saleor/graphql/core/types/__init__.py
+++ b/saleor/graphql/core/types/__init__.py
@@ -43,7 +43,6 @@ from .common import (
MetadataError,
NonNullList,
OrderError,
- OrderSettingsError,
PageError,
PaymentError,
Permission,
@@ -132,7 +131,6 @@ __all__ = [
"MoneyRange",
"NonNullList",
"OrderError",
- "OrderSettingsError",
"PageError",
"PaymentError",
"Permission",
diff --git a/saleor/graphql/core/types/common.py b/saleor/graphql/core/types/common.py
index ff1bd389cf..28496759a5 100644
--- a/saleor/graphql/core/types/common.py
+++ b/saleor/graphql/core/types/common.py
@@ -52,7 +52,6 @@ from ..enums import (
MetadataErrorCode,
OrderBulkCreateErrorCode,
OrderErrorCode,
- OrderSettingsErrorCode,
PageErrorCode,
PaymentErrorCode,
PaymentGatewayConfigErrorCode,
@@ -340,13 +339,6 @@ class MenuError(Error):
doc_category = DOC_CATEGORY_MENU
-class OrderSettingsError(Error):
- code = OrderSettingsErrorCode(description="The error code.", required=True)
-
- class Meta:
- doc_category = DOC_CATEGORY_ORDERS
-
-
class GiftCardSettingsError(Error):
code = GiftCardSettingsErrorCode(description="The error code.", required=True)
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 993507d2bc..1a59d05f0c 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -247,13 +247,6 @@ type Query {
"""Return information about the shop."""
shop: Shop!
- """
- Order related settings from site settings. Returns `orderSettings` for the first `channel` in alphabetical order.
-
- Requires one of the following permissions: MANAGE_ORDERS.
- """
- orderSettings: OrderSettings @doc(category: "Orders") @deprecated(reason: "Use the `channel` query to fetch the `orderSettings` field instead.")
-
"""
Gift card related settings from site settings.
@@ -17720,16 +17713,6 @@ type Mutation {
input: AddressInput
): ShopAddressUpdate @doc(category: "Shop")
- """
- Update shop order settings across all channels. Returns `orderSettings` for the first `channel` in alphabetical order.
-
- Requires one of the following permissions: MANAGE_ORDERS.
- """
- orderSettingsUpdate(
- """Fields required to update shop order settings."""
- input: OrderSettingsUpdateInput!
- ): OrderSettingsUpdate @doc(category: "Orders") @deprecated(reason: "Use `channelUpdate` mutation instead.")
-
"""
Update gift card settings.
@@ -23215,47 +23198,6 @@ type ShopAddressUpdate @doc(category: "Shop") {
errors: [ShopError!]!
}
-"""
-Update shop order settings across all channels. Returns `orderSettings` for the first `channel` in alphabetical order.
-
-Requires one of the following permissions: MANAGE_ORDERS.
-"""
-type OrderSettingsUpdate @doc(category: "Orders") {
- """Order settings."""
- orderSettings: OrderSettings
- orderSettingsErrors: [OrderSettingsError!]! @deprecated(reason: "Use `errors` field instead.")
- errors: [OrderSettingsError!]!
-}
-
-type OrderSettingsError @doc(category: "Orders") {
- """
- Name of a field that caused the error. A value of `null` indicates that the error isn't associated with a particular field.
- """
- field: String
-
- """The error message."""
- message: String
-
- """The error code."""
- code: OrderSettingsErrorCode!
-}
-
-enum OrderSettingsErrorCode @doc(category: "Orders") {
- INVALID
-}
-
-input OrderSettingsUpdateInput @doc(category: "Orders") {
- """
- When disabled, all new orders from checkout will be marked as unconfirmed. When enabled orders from checkout will become unfulfilled immediately. By default set to True
- """
- automaticallyConfirmAllNewOrders: Boolean
-
- """
- When enabled, all non-shippable gift card orders will be fulfilled automatically. By default set to True.
- """
- automaticallyFulfillNonShippableGiftCard: Boolean
-}
-
"""
Update gift card settings.
diff --git a/saleor/graphql/shop/mutations/__init__.py b/saleor/graphql/shop/mutations/__init__.py
index 9def9fd02f..7fd828d73c 100644
--- a/saleor/graphql/shop/mutations/__init__.py
+++ b/saleor/graphql/shop/mutations/__init__.py
@@ -1,5 +1,4 @@
from .gift_card_settings_update import GiftCardSettingsUpdate
-from .order_settings_update import OrderSettingsUpdate
from .refund_reason_reference_type_clear import RefundReasonReferenceTypeClear
from .refund_settings_update import RefundSettingsUpdate
from .return_reason_reference_type_clear import ReturnReasonReferenceTypeClear
@@ -14,7 +13,6 @@ from .staff_notification_recipient_update import StaffNotificationRecipientUpdat
__all__ = [
"GiftCardSettingsUpdate",
- "OrderSettingsUpdate",
"RefundSettingsUpdate",
"RefundReasonReferenceTypeClear",
"ReturnSettingsUpdate",
diff --git a/saleor/graphql/shop/mutations/order_settings_update.py b/saleor/graphql/shop/mutations/order_settings_update.py
deleted file mode 100644
index 2f7a7f57a2..0000000000
--- a/saleor/graphql/shop/mutations/order_settings_update.py
+++ /dev/null
@@ -1,89 +0,0 @@
-import graphene
-from django.core.exceptions import ValidationError
-
-from ....channel import models as channel_models
-from ....permission.enums import OrderPermissions
-from ....site.error_codes import OrderSettingsErrorCode
-from ...channel.types import OrderSettings
-from ...core import ResolveInfo
-from ...core.doc_category import DOC_CATEGORY_ORDERS
-from ...core.mutations import BaseMutation
-from ...core.types import BaseInputObjectType, OrderSettingsError
-
-
-class OrderSettingsUpdateInput(BaseInputObjectType):
- automatically_confirm_all_new_orders = graphene.Boolean(
- required=False,
- description="When disabled, all new orders from checkout "
- "will be marked as unconfirmed. When enabled orders from checkout will "
- "become unfulfilled immediately. By default set to True",
- )
- automatically_fulfill_non_shippable_gift_card = graphene.Boolean(
- required=False,
- description="When enabled, all non-shippable gift card orders "
- "will be fulfilled automatically. By default set to True.",
- )
-
- class Meta:
- doc_category = DOC_CATEGORY_ORDERS
-
-
-class OrderSettingsUpdate(BaseMutation):
- order_settings = graphene.Field(OrderSettings, description="Order settings.")
-
- class Arguments:
- input = OrderSettingsUpdateInput(
- required=True, description="Fields required to update shop order settings."
- )
-
- class Meta:
- description = (
- "Update shop order settings across all channels. "
- "Returns `orderSettings` for the first `channel` in alphabetical order. "
- )
- doc_category = DOC_CATEGORY_ORDERS
- permissions = (OrderPermissions.MANAGE_ORDERS,)
- error_type_class = OrderSettingsError
- error_type_field = "order_settings_errors"
-
- @classmethod
- def perform_mutation(cls, _root, info: ResolveInfo, /, **data):
- FIELDS = [
- "automatically_confirm_all_new_orders",
- "automatically_fulfill_non_shippable_gift_card",
- ]
-
- channel = (
- channel_models.Channel.objects.filter(is_active=True)
- .order_by("slug")
- .first()
- )
-
- if channel is None:
- raise ValidationError(
- "There is no active channel available",
- code=OrderSettingsErrorCode.INVALID.value,
- )
-
- cls.check_channel_permissions(info, [channel.id])
-
- update_fields = {}
- for field in FIELDS:
- if field in data["input"]:
- update_fields[field] = data["input"][field]
-
- if update_fields:
- channel_models.Channel.objects.update(**update_fields)
-
- channel.refresh_from_db()
-
- order_settings = OrderSettings(
- automatically_confirm_all_new_orders=(
- channel.automatically_confirm_all_new_orders
- ),
- automatically_fulfill_non_shippable_gift_card=(
- channel.automatically_fulfill_non_shippable_gift_card
- ),
- mark_as_paid_strategy=channel.order_mark_as_paid_strategy,
- )
- return OrderSettingsUpdate(order_settings=order_settings)
diff --git a/saleor/graphql/shop/schema.py b/saleor/graphql/shop/schema.py
index d2f5dfc567..a5f2db5170 100644
--- a/saleor/graphql/shop/schema.py
+++ b/saleor/graphql/shop/schema.py
@@ -1,13 +1,9 @@
import graphene
-from ...channel import models as channel_models
-from ...permission.enums import GiftcardPermissions, OrderPermissions
-from ..channel.types import OrderSettings
-from ..core.context import get_database_connection_name
+from ...permission.enums import GiftcardPermissions
from ..core.descriptions import DEFAULT_DEPRECATION_REASON
from ..core.doc_category import (
DOC_CATEGORY_GIFT_CARDS,
- DOC_CATEGORY_ORDERS,
DOC_CATEGORY_SHOP,
)
from ..core.fields import PermissionsField
@@ -15,7 +11,6 @@ from ..site.dataloaders import load_site_callback
from ..translations.mutations import ShopSettingsTranslate
from .mutations import (
GiftCardSettingsUpdate,
- OrderSettingsUpdate,
RefundReasonReferenceTypeClear,
RefundSettingsUpdate,
ReturnReasonReferenceTypeClear,
@@ -37,17 +32,6 @@ class ShopQueries(graphene.ObjectType):
description="Return information about the shop.",
required=True,
)
- order_settings = PermissionsField(
- OrderSettings,
- description=(
- "Order related settings from site settings. "
- "Returns `orderSettings` for the first `channel` in "
- "alphabetical order."
- ),
- deprecation_reason="Use the `channel` query to fetch the `orderSettings` field instead.",
- permissions=[OrderPermissions.MANAGE_ORDERS],
- doc_category=DOC_CATEGORY_ORDERS,
- )
gift_card_settings = PermissionsField(
GiftCardSettings,
description="Gift card related settings from site settings.",
@@ -73,26 +57,6 @@ class ShopQueries(graphene.ObjectType):
def resolve_shop(self, _info):
return Shop()
- def resolve_order_settings(self, info):
- channel = (
- channel_models.Channel.objects.using(
- get_database_connection_name(info.context)
- )
- .filter(is_active=True)
- .order_by("slug")
- .first()
- )
- if channel is None:
- return None
- return OrderSettings(
- automatically_confirm_all_new_orders=(
- channel.automatically_confirm_all_new_orders
- ),
- automatically_fulfill_non_shippable_gift_card=(
- channel.automatically_fulfill_non_shippable_gift_card
- ),
- )
-
@load_site_callback
def resolve_gift_card_settings(self, _info, site):
return site.settings
@@ -121,9 +85,6 @@ class ShopMutations(graphene.ObjectType):
shop_settings_translate = ShopSettingsTranslate.Field()
shop_address_update = ShopAddressUpdate.Field()
- order_settings_update = OrderSettingsUpdate.Field(
- deprecation_reason="Use `channelUpdate` mutation instead."
- )
gift_card_settings_update = GiftCardSettingsUpdate.Field()
refund_settings_update = RefundSettingsUpdate.Field()
refund_reason_reference_clear = RefundReasonReferenceTypeClear.Field()
diff --git a/saleor/graphql/shop/tests/mutations/test_order_settings_update.py b/saleor/graphql/shop/tests/mutations/test_order_settings_update.py
deleted file mode 100644
index a5e2fca025..0000000000
--- a/saleor/graphql/shop/tests/mutations/test_order_settings_update.py
+++ /dev/null
@@ -1,147 +0,0 @@
-from ....tests.utils import assert_no_permission, get_graphql_content
-
-ORDER_SETTINGS_UPDATE_MUTATION = """
- mutation orderSettings($confirmOrders: Boolean, $fulfillGiftCards: Boolean) {
- orderSettingsUpdate(
- input: {
- automaticallyConfirmAllNewOrders: $confirmOrders
- automaticallyFulfillNonShippableGiftCard: $fulfillGiftCards
- }
- ) {
- orderSettings {
- automaticallyConfirmAllNewOrders
- automaticallyFulfillNonShippableGiftCard
- markAsPaidStrategy
- }
- }
- }
-"""
-
-
-def test_order_settings_update_by_staff(
- staff_api_client, permission_group_manage_orders, channel_USD, channel_PLN
-):
- # given
- permission_group_manage_orders.user_set.add(staff_api_client.user)
-
- # when
- response = staff_api_client.post_graphql(
- ORDER_SETTINGS_UPDATE_MUTATION,
- {"confirmOrders": False, "fulfillGiftCards": False},
- )
- content = get_graphql_content(response)
-
- # then
- response_settings = content["data"]["orderSettingsUpdate"]["orderSettings"]
- assert response_settings["automaticallyConfirmAllNewOrders"] is False
- assert response_settings["automaticallyFulfillNonShippableGiftCard"] is False
- channel_PLN.refresh_from_db()
- channel_USD.refresh_from_db()
- assert channel_PLN.automatically_confirm_all_new_orders is False
- assert channel_PLN.automatically_fulfill_non_shippable_gift_card is False
- assert channel_USD.automatically_confirm_all_new_orders is False
- assert channel_USD.automatically_fulfill_non_shippable_gift_card is False
-
-
-def test_order_settings_update_by_staff_no_channel_access(
- staff_api_client,
- permission_group_all_perms_channel_USD_only,
- channel_USD,
- channel_PLN,
-):
- # given
- permission_group_all_perms_channel_USD_only.user_set.add(staff_api_client.user)
- channel_USD.is_active = False
- channel_USD.save(update_fields=["is_active"])
-
- # when
- response = staff_api_client.post_graphql(
- ORDER_SETTINGS_UPDATE_MUTATION,
- {"confirmOrders": False, "fulfillGiftCards": False},
- )
-
- # then
- assert_no_permission(response)
-
-
-def test_order_settings_update_by_staff_nothing_changed(
- staff_api_client, permission_group_manage_orders, channel_USD, channel_PLN
-):
- # given
- permission_group_manage_orders.user_set.add(staff_api_client.user)
- QUERY = """
- mutation {
- orderSettingsUpdate(
- input: {}
- ) {
- orderSettings {
- automaticallyConfirmAllNewOrders
- automaticallyFulfillNonShippableGiftCard
- }
- }
- }
- """
-
- # when
- response = staff_api_client.post_graphql(
- QUERY,
- {},
- )
- content = get_graphql_content(response)
-
- # then
- response_settings = content["data"]["orderSettingsUpdate"]["orderSettings"]
- assert response_settings["automaticallyConfirmAllNewOrders"] is True
- assert response_settings["automaticallyFulfillNonShippableGiftCard"] is True
- channel_PLN.refresh_from_db()
- channel_USD.refresh_from_db()
- assert channel_PLN.automatically_confirm_all_new_orders is True
- assert channel_PLN.automatically_fulfill_non_shippable_gift_card is True
- assert channel_USD.automatically_confirm_all_new_orders is True
- assert channel_USD.automatically_fulfill_non_shippable_gift_card is True
-
-
-def test_order_settings_update_by_app(
- app_api_client, permission_manage_orders, channel_USD, channel_PLN
-):
- # given
- app_api_client.app.permissions.set([permission_manage_orders])
-
- # when
- response = app_api_client.post_graphql(
- ORDER_SETTINGS_UPDATE_MUTATION,
- {"confirmOrders": False, "fulfillGiftCards": False},
- )
- content = get_graphql_content(response)
-
- # then
- response_settings = content["data"]["orderSettingsUpdate"]["orderSettings"]
- assert response_settings["automaticallyConfirmAllNewOrders"] is False
- assert response_settings["automaticallyFulfillNonShippableGiftCard"] is False
- channel_PLN.refresh_from_db()
- channel_USD.refresh_from_db()
- assert channel_PLN.automatically_confirm_all_new_orders is False
- assert channel_PLN.automatically_fulfill_non_shippable_gift_card is False
- assert channel_USD.automatically_confirm_all_new_orders is False
- assert channel_USD.automatically_fulfill_non_shippable_gift_card is False
-
-
-def test_order_settings_update_by_user_without_permissions(
- user_api_client, channel_USD, channel_PLN
-):
- # given
-
- # when
- response = user_api_client.post_graphql(
- ORDER_SETTINGS_UPDATE_MUTATION,
- {"confirmOrders": False, "fulfillGiftCards": False},
- )
-
- # then
- assert_no_permission(response)
- channel_PLN.refresh_from_db()
- channel_USD.refresh_from_db()
- assert channel_PLN.automatically_confirm_all_new_orders is True
- assert channel_PLN.automatically_fulfill_non_shippable_gift_card is True
- assert channel_USD.automatically_confirm_all_new_orders is True
- assert channel_USD.automatically_fulfill_non_shippable_gift_card is True
diff --git a/saleor/graphql/shop/tests/queries/test_order_settings.py b/saleor/graphql/shop/tests/queries/test_order_settings.py
deleted file mode 100644
index 0cb55f123f..0000000000
--- a/saleor/graphql/shop/tests/queries/test_order_settings.py
+++ /dev/null
@@ -1,68 +0,0 @@
-from ....tests.utils import assert_no_permission, get_graphql_content
-
-ORDER_SETTINGS_QUERY = """
- query orderSettings {
- orderSettings {
- automaticallyConfirmAllNewOrders
- automaticallyFulfillNonShippableGiftCard
- }
- }
-"""
-
-
-def test_order_settings_query_one_channel(
- staff_api_client, permission_manage_orders, channel_USD
-):
- # given
- channel_USD.automatically_confirm_all_new_orders = False
- channel_USD.automatically_fulfill_non_shippable_gift_card = True
- channel_USD.save()
-
- staff_api_client.user.user_permissions.add(permission_manage_orders)
-
- # when
- response = staff_api_client.post_graphql(ORDER_SETTINGS_QUERY)
-
- # then
- content = get_graphql_content(response)
-
- assert content["data"]["orderSettings"]["automaticallyConfirmAllNewOrders"] is False
- assert (
- content["data"]["orderSettings"]["automaticallyFulfillNonShippableGiftCard"]
- is True
- )
-
-
-def test_order_settings_query_multiple_channels(
- staff_api_client, permission_manage_orders, channel_USD, channel_PLN
-):
- # given
- channel_USD.automatically_confirm_all_new_orders = False
- channel_USD.automatically_fulfill_non_shippable_gift_card = True
- channel_USD.save()
-
- channel_PLN.automatically_confirm_all_new_orders = True
- channel_PLN.automatically_fulfill_non_shippable_gift_card = False
- channel_PLN.save()
-
- staff_api_client.user.user_permissions.add(permission_manage_orders)
-
- # when
- response = staff_api_client.post_graphql(ORDER_SETTINGS_QUERY)
-
- # then
- content = get_graphql_content(response)
-
- assert content["data"]["orderSettings"]["automaticallyConfirmAllNewOrders"] is True
- assert (
- content["data"]["orderSettings"]["automaticallyFulfillNonShippableGiftCard"]
- is False
- )
-
-
-def test_order_settings_query_as_user(user_api_client, channel_USD, channel_PLN):
- # when
- response = user_api_client.post_graphql(ORDER_SETTINGS_QUERY)
-
- # then
- assert_no_permission(response)
diff --git a/saleor/site/error_codes.py b/saleor/site/error_codes.py
index 2b801d68da..94faeed258 100644
--- a/saleor/site/error_codes.py
+++ b/saleor/site/error_codes.py
@@ -6,10 +6,6 @@ class SiteErrorCode(Enum):
GRAPHQL_ERROR = "graphql_error"
-class OrderSettingsErrorCode(Enum):
- INVALID = "invalid"
-
-
class GiftCardSettingsErrorCode(Enum):
INVALID = "invalid"
REQUIRED = "required"