Skip to content

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

Remove the deprecated preorder GraphQL API (#19674)

Lukasz Ostrowski8c7815d83922
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 20777a8795..008b85eb7c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,15 @@ All notable, unreleased changes to this project will be documented in this file.
- Removed the deprecated `orderAddNote` mutation, along with the `OrderAddNote` type and `OrderAddNoteInput` input. Use the `orderNoteAdd` mutation instead.
- Removed the deprecated `exportGiftCards` and `exportVoucherCodes` mutations, along with the `ExportGiftCards`, `ExportGiftCardsInput`, `ExportVoucherCodes` and `ExportVoucherCodesInput` types. Fetch the data with the `giftCards` and `voucher` queries and format it in your app instead.
- Removed the `GIFT_CARD_EXPORT_COMPLETED` and `VOUCHER_CODE_EXPORT_COMPLETED` webhook event types, along with the `GiftCardExportCompleted` and `VoucherCodeExportCompleted` subscription types. They were emitted only by the removed `exportGiftCards` and `exportVoucherCodes` mutations. Existing webhook subscriptions to these events are deleted by a migration; a webhook left with no other events will stop being triggered.
+- Removed the preorder GraphQL API, deprecated in 3.23. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit. Removed:
+ - the `productVariantPreorderDeactivate` mutation, along with the `ProductVariantPreorderDeactivate` type,
+ - the `PreorderData` type and the `ProductVariant.preorder` field, and the `PreorderThreshold` type and the `ProductVariantChannelListing.preorderThreshold` field,
+ - the `PreorderSettingsInput` input and the `preorder` field on `ProductVariantInput`, `ProductVariantCreateInput`, `ProductVariantBulkCreateInput` and `ProductVariantBulkUpdateInput`,
+ - the `preorderThreshold` input field on `ProductVariantChannelListingAddInput` and `ChannelListingUpdateInput`,
+ - the `hasPreorderedVariants` filter on `ProductFilterInput` and `ProductWhereInput`, and the `isPreorder` filter on `ProductVariantFilterInput` and `OrderFilterInput`,
+ - the `PREORDER_VARIANT_CANNOT_BE_DEACTIVATED` value from the `ProductErrorCode` enum.
+
+ Variants already in preorder keep being handled by the checkout and order flow; a preorder with an end date is still deactivated automatically once that date passes. The preorder database columns will be dropped in a later release.
- Removed the `DIGITAL_LINKS` value from the `OrderEventsEmailsEnum` enum and the `DIGITAL_LINK_DOWNLOADED` value from the `CustomerEventsEnum` enum. Events with these types were deleted in 3.23, along with the legacy digital content feature that emitted them.
- Removed the always-empty `digital_lines` key from the fulfillment confirmation notification payload. Use `physical_lines`, which holds every line of the fulfillment.
- Attribute value and bulk attribute mutations now require the permission matching the attribute's type: `MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES` for `PRODUCT_TYPE` attributes, `MANAGE_PAGE_TYPES_AND_ATTRIBUTES` for `PAGE_TYPE` attributes, and `MANAGE_CUSTOMER_TYPES_AND_ATTRIBUTES` for `CUSTOMER_TYPE` attributes. Previously each mutation required a single fixed permission regardless of the attribute's type, which let a requestor modify attributes of a type they were not authorized for.
diff --git a/saleor/graphql/core/descriptions.py b/saleor/graphql/core/descriptions.py
index 98715f1255..a161aabe7b 100644
--- a/saleor/graphql/core/descriptions.py
+++ b/saleor/graphql/core/descriptions.py
@@ -28,22 +28,6 @@ DEPRECATED_LEGACY_PAYMENTS = (
DEPRECATED_LEGACY_PAYMENTS_TYPE_DESCRIPTION = "\n\n" + DEPRECATED_LEGACY_PAYMENTS
-DEPRECATED_PREORDER = (
- "Preorder is deprecated and will be removed. "
- "Model pre-sales with regular stock instead: create the planned quantity in a "
- "warehouse, or set `trackInventory` to false to sell without a stock limit."
-)
-
-# Used on type descriptions, where GraphQL has no `@deprecated` directive. Must not
-# embed DEPRECATED_IN_3X_INPUT: `schema_printer.print_description` truncates a
-# description at that marker, which would drop the reason entirely.
-DEPRECATED_PREORDER_TYPE_DESCRIPTION = "\n\nDEPRECATED: " + DEPRECATED_PREORDER
-
-# `schema_printer.print_input_value` turns this into a real `@deprecated` directive,
-# but only when the description carries the DEPRECATED_IN_3X_INPUT marker verbatim.
-DEPRECATED_PREORDER_INPUT = f"{DEPRECATED_IN_3X_INPUT} {DEPRECATED_PREORDER}"
-
-
PREVIEW_FEATURE = (
"\n\nNote: this API is currently in Feature Preview and can be subject to "
"changes at later point."
diff --git a/saleor/graphql/core/enums.py b/saleor/graphql/core/enums.py
index 78dd153e63..00422810c7 100644
--- a/saleor/graphql/core/enums.py
+++ b/saleor/graphql/core/enums.py
@@ -35,7 +35,6 @@ from ...translations import error_codes as translatable_error_codes
from ...warehouse import error_codes as warehouse_error_codes
from ...webhook import error_codes as webhook_error_codes
from ..notifications import error_codes as external_notifications_error_codes
-from .descriptions import DEPRECATED_PREORDER
from .doc_category import (
DOC_CATEGORY_APPS,
DOC_CATEGORY_ATTRIBUTES,
@@ -429,18 +428,8 @@ PermissionGroupErrorCode: Final[graphene.Enum] = graphene.Enum.from_enum(
PermissionGroupErrorCode.doc_category = DOC_CATEGORY_USERS
-def product_error_code_deprecation_reason(enum):
- preorder_code = (
- product_error_codes.ProductErrorCode.PREORDER_VARIANT_CANNOT_BE_DEACTIVATED
- )
- if enum == preorder_code:
- return DEPRECATED_PREORDER
- return None
-
-
ProductErrorCode: Final[graphene.Enum] = graphene.Enum.from_enum(
- product_error_codes.ProductErrorCode,
- deprecation_reason=product_error_code_deprecation_reason,
+ product_error_codes.ProductErrorCode
)
ProductErrorCode.doc_category = DOC_CATEGORY_PRODUCTS
diff --git a/saleor/graphql/order/filters.py b/saleor/graphql/order/filters.py
index 33c07a1cca..d6e267fc8d 100644
--- a/saleor/graphql/order/filters.py
+++ b/saleor/graphql/order/filters.py
@@ -6,7 +6,6 @@ import graphene
from django.core.exceptions import ValidationError
from django.core.validators import validate_email
from django.db.models import Exists, OuterRef, Q, QuerySet, Value
-from django.utils import timezone
from graphql.error import GraphQLError
from ...core.postgres import FlatConcat
@@ -17,11 +16,10 @@ from ...invoice.models import Invoice
from ...order.models import Fulfillment, FulfillmentLine, Order, OrderEvent, OrderLine
from ...payment import ChargeStatus, PaymentMethodType
from ...payment.models import TransactionItem
-from ...product.models import ProductVariant
from ...warehouse.models import Stock, Warehouse
from ..account.filters import AddressFilterInput, filter_address
from ..channel.filters import get_currency_from_filter_data
-from ..core.descriptions import ADDED_IN_322, DEPRECATED_PREORDER_INPUT
+from ..core.descriptions import ADDED_IN_322
from ..core.doc_category import DOC_CATEGORY_ORDERS
from ..core.filters import (
GlobalIDMultipleChoiceFilter,
@@ -208,27 +206,6 @@ def filter_is_click_and_collect(qs, _, values):
return qs
-def filter_is_preorder(qs, _, values):
- if values is not None:
- variants = (
- ProductVariant.objects.using(qs.db)
- .filter(
- Q(is_preorder=True)
- & (
- Q(preorder_end_date__isnull=True)
- | Q(preorder_end_date__gte=timezone.now())
- )
- )
- .values("id")
- )
- lines = OrderLine.objects.using(qs.db).filter(
- Exists(variants.filter(id=OuterRef("variant_id")))
- )
- lookup = Exists(lines.filter(order_id=OuterRef("id")))
- qs = qs.filter(lookup) if values is True else qs.exclude(lookup)
- return qs
-
-
def filter_gift_card_used(qs, _, value):
return filter_by_gift_card(qs, value, GiftCardEvents.USED_IN_ORDER)
@@ -402,13 +379,6 @@ class OrderFilter(DraftOrderFilter):
is_click_and_collect = django_filters.BooleanFilter(
method=filter_is_click_and_collect
)
- is_preorder = django_filters.BooleanFilter(
- method=filter_is_preorder,
- help_text=(
- "Filter by orders containing a variant that is currently in preorder."
- f"{DEPRECATED_PREORDER_INPUT}"
- ),
- )
ids = GlobalIDMultipleChoiceFilter(method=filter_order_by_id)
checkout_tokens = ListObjectTypeFilter(
input_class=UUIDScalar, method=filter_by_checkout_tokens
diff --git a/saleor/graphql/order/tests/queries/test_order_with_filter.py b/saleor/graphql/order/tests/queries/test_order_with_filter.py
index a644e20d43..c9ce23dae0 100644
--- a/saleor/graphql/order/tests/queries/test_order_with_filter.py
+++ b/saleor/graphql/order/tests/queries/test_order_with_filter.py
@@ -541,52 +541,6 @@ def test_order_query_with_filter_is_click_and_collect_false(
}
-@freeze_time("2021-11-01 12:00:01")
-def test_order_query_with_filter_is_preorder_true(
- staff_api_client,
- permission_group_manage_orders,
- preorders,
-):
- # given
- permission_group_manage_orders.user_set.add(staff_api_client.user)
- variables = {"filter": {"isPreorder": True}}
-
- # when
- response = staff_api_client.post_graphql(ORDERS_QUERY_WITH_FILTERS, variables)
-
- # then
- content = get_graphql_content(response)
- returned_orders = content["data"]["orders"]["edges"]
- assert len(returned_orders) == len(preorders)
- assert {order["node"]["id"] for order in returned_orders} == {
- graphene.Node.to_global_id("Order", order.pk) for order in preorders
- }
-
-
-@freeze_time("2021-11-01 12:00:01")
-def test_order_query_with_filter_is_preorder_false(
- staff_api_client,
- permission_group_manage_orders,
- preorders,
-):
- # given
- permission_group_manage_orders.user_set.add(staff_api_client.user)
- variables = {"filter": {"isPreorder": False}}
-
- # when
- response = staff_api_client.post_graphql(ORDERS_QUERY_WITH_FILTERS, variables)
-
- # then
- content = get_graphql_content(response)
- returned_orders = content["data"]["orders"]["edges"]
- preorders_ids = {
- graphene.Node.to_global_id("Order", order.pk) for order in preorders
- }
- preorder_ids = {order["node"]["id"] for order in returned_orders}
- for order_id in preorders_ids:
- assert order_id not in preorder_ids
-
-
@pytest.mark.parametrize(
("orders_filter", "count"),
[
diff --git a/saleor/graphql/product/bulk_mutations/product_variant_bulk_create.py b/saleor/graphql/product/bulk_mutations/product_variant_bulk_create.py
index 497c16392e..c8d5a7bad0 100644
--- a/saleor/graphql/product/bulk_mutations/product_variant_bulk_create.py
+++ b/saleor/graphql/product/bulk_mutations/product_variant_bulk_create.py
@@ -730,14 +730,6 @@ class ProductVariantBulkCreate(BaseMutation):
if sku is not None:
cleaned_input["sku"] = clean_variant_sku(sku)
- preorder_settings = cleaned_input.get("preorder")
- if preorder_settings:
- cleaned_input["is_preorder"] = True
- cleaned_input["preorder_global_threshold"] = preorder_settings.get(
- "global_threshold"
- )
- cleaned_input["preorder_end_date"] = preorder_settings.get("end_date")
-
base_fields_errors_count = cls.validate_base_fields(
cleaned_input, duplicated_sku, errors, index_error_map, index
)
@@ -845,7 +837,6 @@ class ProductVariantBulkCreate(BaseMutation):
cost_price_amount=listing_data.get("cost_price"),
prior_price_amount=listing_data.get("prior_price"),
currency=listing_data["channel"].currency_code,
- preorder_quantity_threshold=listing_data.get("preorder_threshold"),
)
for listing_data in listings_input
]
diff --git a/saleor/graphql/product/bulk_mutations/product_variant_bulk_update.py b/saleor/graphql/product/bulk_mutations/product_variant_bulk_update.py
index ca705c471c..59a56360ed 100644
--- a/saleor/graphql/product/bulk_mutations/product_variant_bulk_update.py
+++ b/saleor/graphql/product/bulk_mutations/product_variant_bulk_update.py
@@ -17,7 +17,6 @@ from ....warehouse.management import delete_stocks, stock_bulk_update
from ....webhook.event_types import WebhookEventAsyncType
from ....webhook.utils import get_webhooks_for_event
from ...attribute.utils.attribute_assignment import AttributeAssignmentMixin
-from ...core.descriptions import DEPRECATED_PREORDER_INPUT
from ...core.doc_category import DOC_CATEGORY_PRODUCTS
from ...core.enums import ErrorPolicyEnum
from ...core.mutations import BaseMutation, DeprecatedModelMutation
@@ -67,11 +66,6 @@ class ChannelListingUpdateInput(BaseInputObjectType):
price = PositiveDecimal(description="Price of the particular variant in channel.")
cost_price = PositiveDecimal(description="Cost price of the variant in channel.")
prior_price = PositiveDecimal(description="Price of the variant before discount.")
- preorder_threshold = graphene.Int(
- description=(
- f"The threshold for preorder variant in channel.{DEPRECATED_PREORDER_INPUT}"
- )
- )
class Meta:
doc_category = DOC_CATEGORY_PRODUCTS
@@ -411,14 +405,6 @@ class ProductVariantBulkUpdate(BaseMutation):
if sku is not None:
cleaned_input["sku"] = clean_variant_sku(sku)
- preorder_settings = cleaned_input.get("preorder")
- if preorder_settings:
- cleaned_input["is_preorder"] = True
- cleaned_input["preorder_global_threshold"] = preorder_settings.get(
- "global_threshold"
- )
- cleaned_input["preorder_end_date"] = preorder_settings.get("end_date")
-
base_fields_errors_count = cls.validate_base_fields(
cleaned_input, duplicated_sku, index_error_map, index
)
@@ -649,7 +635,6 @@ class ProductVariantBulkUpdate(BaseMutation):
cost_price_amount=listing_data.get("cost_price"),
prior_price_amount=listing_data.get("prior_price"),
currency=listing_data["channel"].currency_code,
- preorder_quantity_threshold=listing_data.get("preorder_threshold"),
)
for listing_data in listings_data
]
@@ -657,10 +642,6 @@ class ProductVariantBulkUpdate(BaseMutation):
if listings_data := listings_input.get("update"):
for listing_data in listings_data:
listing = listing_data["channel_listings"]
- if "preorder_threshold" in listing_data:
- listing.preorder_quantity_threshold = listing_data[
- "preorder_threshold"
- ]
if "price" in listing_data:
listing.price_amount = listing_data["price"]
# set the discounted price the same as price for now, the discounted
@@ -722,9 +703,6 @@ class ProductVariantBulkUpdate(BaseMutation):
"metadata",
"private_metadata",
"external_reference",
- "preorder_end_date",
- "preorder_global_threshold",
- "is_preorder",
],
)
@@ -745,7 +723,6 @@ class ProductVariantBulkUpdate(BaseMutation):
"discounted_price_amount",
"cost_price_amount",
"prior_price_amount",
- "preorder_quantity_threshold",
],
)
if stocks_to_remove:
diff --git a/saleor/graphql/product/filters/product.py b/saleor/graphql/product/filters/product.py
index 5b3a16ce76..20120d6215 100644
--- a/saleor/graphql/product/filters/product.py
+++ b/saleor/graphql/product/filters/product.py
@@ -11,7 +11,6 @@ from ....product.models import (
ProductVariantChannelListing,
)
from ...channel.filters import get_channel_slug_from_filter_data
-from ...core.descriptions import DEPRECATED_PREORDER_INPUT
from ...core.doc_category import DOC_CATEGORY_PRODUCTS
from ...core.filters import (
BooleanWhereFilter,
@@ -55,7 +54,6 @@ from .product_helpers import (
filter_collections,
filter_gift_card,
filter_has_category,
- filter_has_preordered_variants,
filter_minimal_price,
filter_product_types,
filter_products_channel_field_from_date,
@@ -69,7 +67,6 @@ from .product_helpers import (
where_filter_by_categories,
where_filter_gift_card,
where_filter_has_category,
- where_filter_has_preordered_variants,
where_filter_products_channel_field_from_date,
where_filter_products_is_available,
where_filter_stock_availability,
@@ -135,12 +132,6 @@ class ProductFilter(MetadataFilterBase):
help_text="Filter on whether product is a gift card or not.",
)
ids = GlobalIDMultipleChoiceFilter(method=filter_by_id("Product"))
- has_preordered_variants = django_filters.BooleanFilter(
- method=filter_has_preordered_variants,
- help_text=(
- f"Filter by product with preordered variants.{DEPRECATED_PREORDER_INPUT}"
- ),
- )
slugs = ListObjectTypeFilter(input_class=graphene.String, method=filter_slug_list)
class Meta:
@@ -306,12 +297,6 @@ class ProductWhere(MetadataWhereFilterBase):
method=where_filter_gift_card,
help_text="Filter on whether product is a gift card or not.",
)
- has_preordered_variants = BooleanWhereFilter(
- method=where_filter_has_preordered_variants,
- help_text=(
- f"Filter by product with preordered variants.{DEPRECATED_PREORDER_INPUT}"
- ),
- )
updated_at = ObjectTypeWhereFilter(
input_class=DateTimeFilterInput,
method=where_filter_updated_at_range,
diff --git a/saleor/graphql/product/filters/product_helpers.py b/saleor/graphql/product/filters/product_helpers.py
index ef13a32e85..baaead9484 100644
--- a/saleor/graphql/product/filters/product_helpers.py
+++ b/saleor/graphql/product/filters/product_helpers.py
@@ -211,20 +211,6 @@ def filter_has_category(qs, _, value):
return qs.filter(category__isnull=not value)
-def filter_has_preordered_variants(qs, _, value):
- variants = (
- ProductVariant.objects.using(qs.db)
- .filter(is_preorder=True)
- .filter(
- Q(preorder_end_date__isnull=True) | Q(preorder_end_date__gt=timezone.now())
- )
- .values("product_id")
- )
- if value:
- return qs.filter(Exists(variants.filter(product_id=OuterRef("pk"))))
- return qs.filter(~Exists(variants.filter(product_id=OuterRef("pk"))))
-
-
def filter_collections(qs, _, value):
if value:
_, collection_pks = resolve_global_ids_to_primary_keys(
@@ -614,23 +600,6 @@ def where_filter_gift_card(qs, _, value):
return qs.filter(lookup) if value is True else qs.exclude(lookup)
-def where_filter_has_preordered_variants(qs, _, value):
- if value is None:
- return qs.none()
-
- variants = (
- ProductVariant.objects.using(qs.db)
- .filter(is_preorder=True)
- .filter(
- Q(preorder_end_date__isnull=True) | Q(preorder_end_date__gt=timezone.now())
- )
- .values("product_id")
- )
- if value:
- return qs.filter(Exists(variants.filter(product_id=OuterRef("pk"))))
- return qs.filter(~Exists(variants.filter(product_id=OuterRef("pk"))))
-
-
def where_filter_updated_at_range(qs, _, value):
if value is None:
return qs.none()
diff --git a/saleor/graphql/product/filters/product_variant.py b/saleor/graphql/product/filters/product_variant.py
index fde62a463a..64c93c83da 100644
--- a/saleor/graphql/product/filters/product_variant.py
+++ b/saleor/graphql/product/filters/product_variant.py
@@ -2,7 +2,6 @@ import django_filters
import graphene
from django.db.models import Exists, OuterRef, Q
from django.db.models.query import QuerySet
-from django.utils import timezone
from ....attribute.models import (
AssignedVariantAttribute,
@@ -19,7 +18,6 @@ from ...channel.filters import get_channel_slug_from_filter_data
from ...core.descriptions import (
ADDED_IN_322,
ADDED_IN_324,
- DEPRECATED_PREORDER_INPUT,
)
from ...core.doc_category import DOC_CATEGORY_PRODUCTS
from ...core.filters import (
@@ -52,17 +50,6 @@ def filter_sku_list(qs, _, value):
return qs.filter(sku__in=value)
-def filter_is_preorder(qs, _, value):
- if value:
- return qs.filter(is_preorder=True).filter(
- Q(preorder_end_date__isnull=True) | Q(preorder_end_date__gte=timezone.now())
- )
- return qs.filter(
- Q(is_preorder=False)
- | (Q(is_preorder=True)) & Q(preorder_end_date__lt=timezone.now())
- )
-
-
def _get_assigned_variant_attribute_for_attribute_value_qs(
attribute_values: QuerySet[AttributeValue],
db_connection_name: str,
@@ -95,13 +82,6 @@ def filter_variants_by_attributes(
class ProductVariantFilter(MetadataFilterBase):
search = django_filters.CharFilter(method="product_variant_filter_search")
sku = ListObjectTypeFilter(input_class=graphene.String, method=filter_sku_list)
- is_preorder = django_filters.BooleanFilter(
- method=filter_is_preorder,
- help_text=(
- "Filter by variants that are currently in preorder."
- f"{DEPRECATED_PREORDER_INPUT}"
- ),
- )
updated_at = ObjectTypeFilter(
input_class=DateTimeRangeInput, method=filter_updated_at_range
)
diff --git a/saleor/graphql/product/mutations/__init__.py b/saleor/graphql/product/mutations/__init__.py
index fbdd2a2c04..aa23099d1e 100644
--- a/saleor/graphql/product/mutations/__init__.py
+++ b/saleor/graphql/product/mutations/__init__.py
@@ -20,7 +20,6 @@ from .product_type import ProductTypeCreate, ProductTypeDelete, ProductTypeUpdat
from .product_variant import (
ProductVariantCreate,
ProductVariantDelete,
- ProductVariantPreorderDeactivate,
ProductVariantReorder,
ProductVariantSetDefault,
ProductVariantUpdate,
@@ -50,7 +49,6 @@ __all__ = [
"ProductUpdate",
"ProductVariantCreate",
"ProductVariantDelete",
- "ProductVariantPreorderDeactivate",
"ProductVariantReorder",
"ProductVariantSetDefault",
"ProductVariantUpdate",
diff --git a/saleor/graphql/product/mutations/channels.py b/saleor/graphql/product/mutations/channels.py
index 9072314a38..e761d32745 100644
--- a/saleor/graphql/product/mutations/channels.py
+++ b/saleor/graphql/product/mutations/channels.py
@@ -22,10 +22,7 @@ from ...channel.mutations import BaseChannelListingMutation
from ...channel.types import Channel
from ...core import ResolveInfo
from ...core.context import ChannelContext
-from ...core.descriptions import (
- DEPRECATED_IN_3X_INPUT,
- DEPRECATED_PREORDER_INPUT,
-)
+from ...core.descriptions import DEPRECATED_IN_3X_INPUT
from ...core.doc_category import DOC_CATEGORY_PRODUCTS
from ...core.mutations import BaseMutation
from ...core.scalars import Date, DateTime, PositiveDecimal
@@ -396,11 +393,6 @@ class ProductVariantChannelListingAddInput(BaseInputObjectType):
"promotion information required by customer protection laws such as EU Omnibus "
"directive."
)
- preorder_threshold = graphene.Int(
- description=(
- f"The threshold for preorder variant in channel.{DEPRECATED_PREORDER_INPUT}"
- )
- )
class Meta:
doc_category = DOC_CATEGORY_PRODUCTS
@@ -541,10 +533,6 @@ class ProductVariantChannelListingUpdate(BaseMutation):
defaults["prior_price_amount"] = channel_listing_data.get(
"prior_price", None
)
- if "preorder_threshold" in channel_listing_data.keys():
- defaults["preorder_quantity_threshold"] = channel_listing_data.get(
- "preorder_threshold", None
- )
ProductVariantChannelListing.objects.update_or_create(
variant=variant,
channel=channel,
diff --git a/saleor/graphql/product/mutations/product_variant/__init__.py b/saleor/graphql/product/mutations/product_variant/__init__.py
index dbbb5ce2e8..e530eb8420 100644
--- a/saleor/graphql/product/mutations/product_variant/__init__.py
+++ b/saleor/graphql/product/mutations/product_variant/__init__.py
@@ -1,6 +1,5 @@
from .product_variant_create import ProductVariantCreate
from .product_variant_delete import ProductVariantDelete
-from .product_variant_preorder_deactivate import ProductVariantPreorderDeactivate
from .product_variant_reorder import ProductVariantReorder
from .product_variant_set_default import ProductVariantSetDefault
from .product_variant_update import ProductVariantUpdate
@@ -10,7 +9,6 @@ from .variant_media_unassign import VariantMediaUnassign
__all__ = [
"ProductVariantCreate",
"ProductVariantDelete",
- "ProductVariantPreorderDeactivate",
"ProductVariantReorder",
"ProductVariantSetDefault",
"ProductVariantUpdate",
diff --git a/saleor/graphql/product/mutations/product_variant/product_variant_cleaner.py b/saleor/graphql/product/mutations/product_variant/product_variant_cleaner.py
index abe63592f6..2862f4adcd 100644
--- a/saleor/graphql/product/mutations/product_variant/product_variant_cleaner.py
+++ b/saleor/graphql/product/mutations/product_variant/product_variant_cleaner.py
@@ -40,16 +40,6 @@ def clean_quantity_limit(cleaned_input: dict):
)
-def clean_preorder_settings(cleaned_input: dict):
- preorder_settings = cleaned_input.get("preorder")
- if preorder_settings:
- cleaned_input["is_preorder"] = True
- cleaned_input["preorder_global_threshold"] = preorder_settings.get(
- "global_threshold"
- )
- cleaned_input["preorder_end_date"] = preorder_settings.get("end_date")
-
-
def clean_variant_attributes(product_type: "ProductType", attributes: list[dict]):
variant_attributes_ids = set()
variant_attributes_external_refs = set()
diff --git a/saleor/graphql/product/mutations/product_variant/product_variant_create.py b/saleor/graphql/product/mutations/product_variant/product_variant_create.py
index 57ce0ef29c..5731328de4 100644
--- a/saleor/graphql/product/mutations/product_variant/product_variant_create.py
+++ b/saleor/graphql/product/mutations/product_variant/product_variant_create.py
@@ -15,13 +15,9 @@ from ....attribute.utils.attribute_assignment import (
from ....attribute.utils.shared import AttrValuesInput
from ....core import ResolveInfo
from ....core.context import ChannelContext
-from ....core.descriptions import (
- DEPRECATED_PREORDER_INPUT,
- DEPRECATED_PREORDER_TYPE_DESCRIPTION,
-)
from ....core.doc_category import DOC_CATEGORY_PRODUCTS
from ....core.mutations import DeprecatedModelMutation
-from ....core.scalars import DateTime, WeightScalar
+from ....core.scalars import WeightScalar
from ....core.types import BaseInputObjectType, NonNullList, ProductError
from ....core.utils import get_duplicated_values
from ....meta.inputs import MetadataInput, MetadataInputDescription
@@ -39,24 +35,6 @@ from . import product_variant_cleaner as cleaner
T_INPUT_MAP = list[tuple[attribute_models.Attribute, AttrValuesInput]]
-class PreorderSettingsInput(BaseInputObjectType):
- global_threshold = graphene.Int(
- description=(
- f"The global threshold for preorder variant.{DEPRECATED_PREORDER_INPUT}"
- )
- )
- end_date = DateTime(
- description=f"The end date for preorder.{DEPRECATED_PREORDER_INPUT}"
- )
-
- class Meta:
- doc_category = DOC_CATEGORY_PRODUCTS
- description = (
- "Preorder settings for a product variant."
- + DEPRECATED_PREORDER_TYPE_DESCRIPTION
- )
-
-
class ProductVariantInput(BaseInputObjectType):
attributes = NonNullList(
AttributeValueInput,
@@ -73,11 +51,6 @@ class ProductVariantInput(BaseInputObjectType):
)
)
weight = WeightScalar(description="Weight of the Product Variant.", required=False)
- preorder = PreorderSettingsInput(
- description=(
- f"Determines if variant is in preorder.{DEPRECATED_PREORDER_INPUT}"
- )
- )
quantity_limit_per_customer = graphene.Int(
required=False,
description=(
@@ -161,7 +134,6 @@ class ProductVariantCreate(DeprecatedModelMutation):
cls.clean_attributes(cleaned_input, instance)
if "sku" in cleaned_input:
cleaned_input["sku"] = clean_variant_sku(cleaned_input.get("sku"))
- cleaner.clean_preorder_settings(cleaned_input)
return cleaned_input
diff --git a/saleor/graphql/product/mutations/product_variant/product_variant_preorder_deactivate.py b/saleor/graphql/product/mutations/product_variant/product_variant_preorder_deactivate.py
deleted file mode 100644
index fab5e8b8cc..0000000000
--- a/saleor/graphql/product/mutations/product_variant/product_variant_preorder_deactivate.py
+++ /dev/null
@@ -1,70 +0,0 @@
-import graphene
-from django.core.exceptions import ValidationError
-
-from .....core.exceptions import PreorderAllocationError
-from .....core.tracing import traced_atomic_transaction
-from .....permission.enums import ProductPermissions
-from .....product import models
-from .....product.error_codes import ProductErrorCode
-from .....warehouse.management import deactivate_preorder_for_variant
-from ....core import ResolveInfo
-from ....core.context import ChannelContext
-from ....core.descriptions import DEPRECATED_PREORDER_TYPE_DESCRIPTION
-from ....core.doc_category import DOC_CATEGORY_PRODUCTS
-from ....core.mutations import BaseMutation
-from ....core.types import ProductError
-from ....plugins.dataloaders import get_plugin_manager_promise
-from ...types import ProductVariant
-
-
-class ProductVariantPreorderDeactivate(BaseMutation):
- product_variant = graphene.Field(
- ProductVariant, description="Product variant with ended preorder."
- )
-
- class Arguments:
- id = graphene.ID(
- required=True,
- description="ID of a variant which preorder should be deactivated.",
- )
-
- class Meta:
- description = (
- "Deactivates product variant preorder. "
- "It changes all preorder allocation into regular allocation."
- + DEPRECATED_PREORDER_TYPE_DESCRIPTION
- )
- doc_category = DOC_CATEGORY_PRODUCTS
- permissions = (ProductPermissions.MANAGE_PRODUCTS,)
- error_type_class = ProductError
-
- @classmethod
- def perform_mutation( # type: ignore[override]
- cls, _root, info: ResolveInfo, /, *, id
- ):
- qs = models.ProductVariant.objects.all()
- variant = cls.get_node_or_error(
- info, id, field="id", only_type=ProductVariant, qs=qs
- )
- if not variant.is_preorder:
- raise ValidationError(
- {
- "id": ValidationError(
- "This variant is not in preorder.",
- code=ProductErrorCode.INVALID.value,
- )
- }
- )
- # transaction ensures triggering event on commit
- with traced_atomic_transaction():
- try:
- deactivate_preorder_for_variant(variant)
- except PreorderAllocationError as e:
- raise ValidationError(
- str(e),
- code=ProductErrorCode.PREORDER_VARIANT_CANNOT_BE_DEACTIVATED.value,
- ) from e
- manager = get_plugin_manager_promise(info.context).get()
- variant = ChannelContext(node=variant, channel_slug=None)
- cls.call_event(manager.product_variant_updated, variant.node)
- return ProductVariantPreorderDeactivate(product_variant=variant)
diff --git a/saleor/graphql/product/mutations/product_variant/product_variant_update.py b/saleor/graphql/product/mutations/product_variant/product_variant_update.py
index eea130abe0..02dac95e7a 100644
--- a/saleor/graphql/product/mutations/product_variant/product_variant_update.py
+++ b/saleor/graphql/product/mutations/product_variant/product_variant_update.py
@@ -122,7 +122,6 @@ class ProductVariantUpdate(DeprecatedModelMutation):
cls.clean_attributes(cleaned_input, instance)
if "sku" in cleaned_input:
cleaned_input["sku"] = clean_variant_sku(cleaned_input.get("sku"))
- cleaner.clean_preorder_settings(cleaned_input)
return cleaned_input
diff --git a/saleor/graphql/product/mutations/utils.py b/saleor/graphql/product/mutations/utils.py
index b818a473ea..57c291452d 100644
--- a/saleor/graphql/product/mutations/utils.py
+++ b/saleor/graphql/product/mutations/utils.py
@@ -4,11 +4,8 @@ from ....tax.models import TaxClass
PRODUCT_VARIANT_UPDATE_FIELDS = {
"external_reference",
- "is_preorder",
"metadata",
"name",
- "preorder_end_date",
- "preorder_global_threshold",
"private_metadata",
"quantity_limit_per_customer",
"sku",
diff --git a/saleor/graphql/product/schema.py b/saleor/graphql/product/schema.py
index 7be0787b4e..2f001411d0 100644
--- a/saleor/graphql/product/schema.py
+++ b/saleor/graphql/product/schema.py
@@ -16,7 +16,6 @@ from ..core.descriptions import (
ADDED_IN_322,
DEFAULT_DEPRECATION_REASON,
DEPRECATED_IN_3X_INPUT,
- DEPRECATED_PREORDER,
)
from ..core.doc_category import DOC_CATEGORY_PRODUCTS
from ..core.enums import LanguageCodeEnum, ReportingPeriod
@@ -81,7 +80,6 @@ from .mutations import (
ProductUpdate,
ProductVariantCreate,
ProductVariantDelete,
- ProductVariantPreorderDeactivate,
ProductVariantReorder,
ProductVariantSetDefault,
ProductVariantUpdate,
@@ -696,9 +694,5 @@ class ProductMutations(graphene.ObjectType):
product_variant_reorder_attribute_values = (
ProductVariantReorderAttributeValues.Field()
)
- product_variant_preorder_deactivate = ProductVariantPreorderDeactivate.Field(
- deprecation_reason=DEPRECATED_PREORDER
- )
-
variant_media_assign = VariantMediaAssign.Field()
variant_media_unassign = VariantMediaUnassign.Field()
diff --git a/saleor/graphql/product/tests/deprecated/test_product_variant_bulk_create.py b/saleor/graphql/product/tests/deprecated/test_product_variant_bulk_create.py
index 315437bb1e..03636978c1 100644
--- a/saleor/graphql/product/tests/deprecated/test_product_variant_bulk_create.py
+++ b/saleor/graphql/product/tests/deprecated/test_product_variant_bulk_create.py
@@ -1,4 +1,3 @@
-import datetime
from unittest.mock import ANY, patch
from uuid import uuid4
@@ -44,13 +43,6 @@ PRODUCT_VARIANT_BULK_CREATE_MUTATION = """
currency
amount
}
- preorderThreshold {
- quantity
- }
- }
- preorder {
- globalThreshold
- endDate
}
}
count
@@ -584,7 +576,6 @@ def test_product_variant_bulk_create_channel_listings_input(
"amount": variants[0]["channelListings"][0]["costPrice"],
"currency": channel_USD.currency_code,
},
- "preorderThreshold": {"quantity": None},
}
],
},
@@ -601,7 +592,6 @@ def test_product_variant_bulk_create_channel_listings_input(
"amount": variants[1]["channelListings"][0]["costPrice"],
"currency": channel_USD.currency_code,
},
- "preorderThreshold": {"quantity": None},
},
{
"channel": {"slug": channel_PLN.slug},
@@ -613,7 +603,6 @@ def test_product_variant_bulk_create_channel_listings_input(
"amount": variants[1]["channelListings"][1]["costPrice"],
"currency": channel_PLN.currency_code,
},
- "preorderThreshold": {"quantity": None},
},
],
},
@@ -629,124 +618,6 @@ def test_product_variant_bulk_create_channel_listings_input(
)
-def test_product_variant_bulk_create_preorder_channel_listings_input(
- staff_api_client,
- product_available_in_many_channels,
- permission_manage_products,
- size_attribute,
- channel_USD,
- channel_PLN,
-):
- product = product_available_in_many_channels
- ProductChannelListing.objects.filter(product=product, channel=channel_PLN).update(
- is_published=False
- )
- product_variant_count = ProductVariant.objects.count()
- product_id = graphene.Node.to_global_id("Product", product.pk)
- attribute_value_count = size_attribute.values.count()
- size_attribute_id = graphene.Node.to_global_id("Attribute", size_attribute.pk)
- attribute_value = size_attribute.values.last()
-
- global_threshold = 10
- end_date = (
- (datetime.datetime.now(tz=datetime.UTC) + datetime.timedelta(days=3))
- .astimezone()
- .replace(microsecond=0)
- .isoformat()
- )
-
- variants = [
- {
- "sku": str(uuid4())[:12],
- "channelListings": [
- {
- "price": 10.0,
- "costPrice": 11.0,
- "channelId": graphene.Node.to_global_id("Channel", channel_USD.pk),
- "preorderThreshold": 5,
- }
- ],
- "attributes": [{"id": size_attribute_id, "values": [attribute_value.name]}],
- "preorder": {
- "globalThreshold": global_threshold,
- "endDate": end_date,
- },
- },
- {
- "sku": str(uuid4())[:12],
- "attributes": [{"id": size_attribute_id, "values": ["Test-attribute"]}],
- "channelListings": [
- {
- "price": 15.0,
- "costPrice": 16.0,
- "channelId": graphene.Node.to_global_id("Channel", channel_USD.pk),
- "preorderThreshold": None,
- },
- {
- "price": 12.0,
- "costPrice": 13.0,
- "channelId": graphene.Node.to_global_id("Channel", channel_PLN.pk),
- "preorderThreshold": 4,
- },
- ],
- "preorder": {
- "globalThreshold": global_threshold,
- "endDate": end_date,
- },
- },
- ]
-
- variables = {"productId": product_id, "variants": variants}
- staff_api_client.user.user_permissions.add(permission_manage_products)
- response = staff_api_client.post_graphql(
- PRODUCT_VARIANT_BULK_CREATE_MUTATION, variables
- )
- content = get_graphql_content(response)
- data = content["data"]["productVariantBulkCreate"]
- assert not data["errors"]
- assert data["count"] == 2
- assert product_variant_count + 2 == ProductVariant.objects.count()
- assert attribute_value_count + 1 == size_attribute.values.count()
-
- expected_result = {
- variants[0]["sku"]: {
- "sku": variants[0]["sku"],
- "channelListings": [{"preorderThreshold": {"quantity": 5}}],
- "preorder": {
- "globalThreshold": global_threshold,
- "endDate": end_date,
- },
- },
- variants[1]["sku"]: {
- "sku": variants[1]["sku"],
- "channelListings": [
- {"preorderThreshold": {"quantity": None}},
- {"preorderThreshold": {"quantity": 4}},
- ],
- "preorder": {
- "globalThreshold": global_threshold,
- "endDate": end_date,
- },
- },
- }
- for variant_data in data["productVariants"]:
- variant_data.pop("id")
- assert variant_data["sku"] in expected_result
- expected_variant = expected_result[variant_data["sku"]]
- expected_channel_listing_thresholds = [
- channel_listing["preorderThreshold"]["quantity"]
- for channel_listing in expected_variant["channelListings"]
- ]
- assert all(
- channel_listing["preorderThreshold"]["quantity"]
- in expected_channel_listing_thresholds
- for channel_listing in variant_data["channelListings"]
- )
- preorder_data = variant_data["preorder"]
- assert preorder_data["globalThreshold"] == global_threshold
- assert preorder_data["endDate"] == end_date
-
-
def test_product_variant_bulk_create_duplicated_channels(
staff_api_client,
product_available_in_many_channels,
diff --git a/saleor/graphql/product/tests/mutations/test_product_variant_bulk_create.py b/saleor/graphql/product/tests/mutations/test_product_variant_bulk_create.py
index 67f4151bf3..861a04d3d9 100644
--- a/saleor/graphql/product/tests/mutations/test_product_variant_bulk_create.py
+++ b/saleor/graphql/product/tests/mutations/test_product_variant_bulk_create.py
@@ -175,13 +175,6 @@ mutation ProductVariantBulkCreate($variants: [ProductVariantBulkCreateInput!]!,
currency
amount
}
- preorderThreshold {
- quantity
- }
- }
- preorder {
- globalThreshold
- endDate
}
}
errors {
@@ -1832,7 +1825,6 @@ def test_product_variant_bulk_create_channel_listings_input(
"amount": variants[0]["channelListings"][0]["costPrice"],
"currency": channel_USD.currency_code,
},
- "preorderThreshold": {"quantity": None},
}
],
},
@@ -1849,7 +1841,6 @@ def test_product_variant_bulk_create_channel_listings_input(
"amount": variants[1]["channelListings"][0]["costPrice"],
"currency": channel_USD.currency_code,
},
- "preorderThreshold": {"quantity": None},
},
{
"channel": {"slug": channel_PLN.slug},
@@ -1861,7 +1852,6 @@ def test_product_variant_bulk_create_channel_listings_input(
"amount": variants[1]["channelListings"][1]["costPrice"],
"currency": channel_PLN.currency_code,
},
- "preorderThreshold": {"quantity": None},
},
],
},
@@ -1895,131 +1885,6 @@ def test_product_variant_bulk_create_channel_listings_input(
)
-def test_product_variant_bulk_create_preorder_channel_listings_input(
- staff_api_client,
- product_available_in_many_channels,
- permission_manage_products,
- size_attribute,
- channel_USD,
- channel_PLN,
-):
- # given
- product = product_available_in_many_channels
- ProductChannelListing.objects.filter(product=product, channel=channel_PLN).update(
- is_published=False
- )
- product_variant_count = ProductVariant.objects.count()
- product_id = graphene.Node.to_global_id("Product", product.pk)
- attribute_value_count = size_attribute.values.count()
- size_attribute_id = graphene.Node.to_global_id("Attribute", size_attribute.pk)
- attribute_value = size_attribute.values.last()
-
- global_threshold = 10
- end_date = (
- (datetime.datetime.now(tz=datetime.UTC) + datetime.timedelta(days=3))
- .astimezone()
- .replace(microsecond=0)
- .isoformat()
- )
-
- variants = [
- {
- "sku": str(uuid4())[:12],
- "channelListings": [
- {
- "price": 10.0,
- "costPrice": 11.0,
- "channelId": graphene.Node.to_global_id("Channel", channel_USD.pk),
- "preorderThreshold": 5,
- }
- ],
- "attributes": [{"id": size_attribute_id, "values": [attribute_value.name]}],
- "preorder": {
- "globalThreshold": global_threshold,
- "endDate": end_date,
- },
- },
- {
- "sku": str(uuid4())[:12],
- "attributes": [{"id": size_attribute_id, "values": ["Test-attribute"]}],
- "channelListings": [
- {
- "price": 15.0,
- "costPrice": 16.0,
- "channelId": graphene.Node.to_global_id("Channel", channel_USD.pk),
- "preorderThreshold": None,
- },
- {
- "price": 12.0,
- "costPrice": 13.0,
- "channelId": graphene.Node.to_global_id("Channel", channel_PLN.pk),
- "preorderThreshold": 4,
- },
- ],
- "preorder": {
- "globalThreshold": global_threshold,
- "endDate": end_date,
- },
- },
- ]
-
- variables = {"productId": product_id, "variants": variants}
-
- # when
- staff_api_client.user.user_permissions.add(permission_manage_products)
- response = staff_api_client.post_graphql(
- PRODUCT_VARIANT_BULK_CREATE_MUTATION, variables
- )
- content = get_graphql_content(response)
- data = content["data"]["productVariantBulkCreate"]
- expected_result = {
- variants[0]["sku"]: {
- "sku": variants[0]["sku"],
- "channelListings": [{"preorderThreshold": {"quantity": 5}}],
- "preorder": {
- "globalThreshold": global_threshold,
- "endDate": end_date,
- },
- },
- variants[1]["sku"]: {
- "sku": variants[1]["sku"],
- "channelListings": [
- {"preorderThreshold": {"quantity": None}},
- {"preorderThreshold": {"quantity": 4}},
- ],
- "preorder": {
- "globalThreshold": global_threshold,
- "endDate": end_date,
- },
- },
- }
-
- # then
- assert not data["results"][0]["errors"]
- assert not data["results"][1]["errors"]
- assert data["count"] == 2
- assert product_variant_count + 2 == ProductVariant.objects.count()
- assert attribute_value_count + 1 == size_attribute.values.count()
-
- for result in data["results"]:
- variant_data = result["productVariant"]
- variant_data.pop("id")
- assert variant_data["sku"] in expected_result
- expected_variant = expected_result[variant_data["sku"]]
- expected_channel_listing_thresholds = [
- channel_listing["preorderThreshold"]["quantity"]
- for channel_listing in expected_variant["channelListings"]
- ]
- assert all(
- channel_listing["preorderThreshold"]["quantity"]
- in expected_channel_listing_thresholds
- for channel_listing in variant_data["channelListings"]
- )
- preorder_data = variant_data["preorder"]
- assert preorder_data["globalThreshold"] == global_threshold
- assert preorder_data["endDate"] == end_date
-
-
def test_product_variant_bulk_create_duplicated_channels(
staff_api_client,
product_available_in_many_channels,
diff --git a/saleor/graphql/product/tests/mutations/test_product_variant_bulk_update.py b/saleor/graphql/product/tests/mutations/test_product_variant_bulk_update.py
index 8ecf0aa4f1..c90f94cfc0 100644
--- a/saleor/graphql/product/tests/mutations/test_product_variant_bulk_update.py
+++ b/saleor/graphql/product/tests/mutations/test_product_variant_bulk_update.py
@@ -69,9 +69,6 @@ PRODUCT_VARIANT_BULK_UPDATE_MUTATION = """
currency
amount
}
- preorderThreshold {
- quantity
- }
}
attributes {
attribute {
@@ -184,10 +181,6 @@ PRODUCT_VARIANT_BULK_UPDATE_MUTATION = """
datetime: value
}
}
- preorder {
- globalThreshold
- endDate
- }
}
}
count
@@ -232,10 +225,6 @@ def test_product_variant_bulk_update(
{
"id": variant_id,
"name": new_name,
- "preorder": {
- "endDate": "2022-12-12T12:12:12Z",
- "globalThreshold": 10,
- },
"metadata": [{"key": metadata_key, "value": metadata_value}],
}
]
@@ -265,12 +254,6 @@ def test_product_variant_bulk_update(
for rule in get_active_catalogue_promotion_rules():
assert rule.variants_dirty
- variant.refresh_from_db()
-
- assert variant.preorder_end_date
- assert variant.preorder_global_threshold
- assert variant.is_preorder
-
@pytest.mark.parametrize(
"error_policy",
diff --git a/saleor/graphql/product/tests/mutations/test_product_variant_create.py b/saleor/graphql/product/tests/mutations/test_product_variant_create.py
index 7f1881251e..d6c601806f 100644
--- a/saleor/graphql/product/tests/mutations/test_product_variant_create.py
+++ b/saleor/graphql/product/tests/mutations/test_product_variant_create.py
@@ -158,10 +158,6 @@ mutation createVariant($input: ProductVariantCreateInput!) {
slug
}
}
- preorder {
- globalThreshold
- endDate
- }
metadata {
key
value
@@ -379,58 +375,6 @@ def test_create_variant_empty_product_id(
assert error["code"] == ProductErrorCode.INVALID.name
-@patch("saleor.plugins.manager.PluginsManager.product_variant_created")
-@patch("saleor.plugins.manager.PluginsManager.product_variant_updated")
-def test_create_variant_preorder(
- updated_webhook_mock,
- created_webhook_mock,
- staff_api_client,
- product,
- product_type,
- permission_manage_products,
-):
- query = CREATE_VARIANT_MUTATION
- product_id = graphene.Node.to_global_id("Product", product.pk)
- attribute_id = graphene.Node.to_global_id(
- "Attribute", product_type.variant_attributes.first().pk
- )
- variant_value = "test-value"
- global_threshold = 10
- end_date = (
- (datetime.datetime.now(tz=datetime.UTC) + datetime.timedelta(days=3))
- .astimezone()
- .replace(microsecond=0)
- .isoformat()
- )
-
- variables = {
- "input": {
- "product": product_id,
- "sku": "1",
- "weight": 10.22,
- "attributes": [{"id": attribute_id, "values": [variant_value]}],
- "preorder": {
- "globalThreshold": global_threshold,
- "endDate": end_date,
- },
- }
- }
-
- response = staff_api_client.post_graphql(
- query, variables, permissions=[permission_manage_products]
- )
- content = get_graphql_content(response)["data"]["productVariantCreate"]
-
- assert not content["errors"]
- data = content["productVariant"]
- assert data["name"] == variant_value
-
- assert data["preorder"]["globalThreshold"] == global_threshold
- assert data["preorder"]["endDate"] == end_date
- created_webhook_mock.assert_called_once_with(product.variants.last())
- updated_webhook_mock.assert_not_called()
-
-
@patch("saleor.plugins.manager.PluginsManager.product_variant_created")
@patch("saleor.plugins.manager.PluginsManager.product_variant_updated")
def test_create_variant_no_required_attributes(
diff --git a/saleor/graphql/product/tests/mutations/test_product_variant_preorder_deactivate.py b/saleor/graphql/product/tests/mutations/test_product_variant_preorder_deactivate.py
deleted file mode 100644
index 7458190af5..0000000000
--- a/saleor/graphql/product/tests/mutations/test_product_variant_preorder_deactivate.py
+++ /dev/null
@@ -1,176 +0,0 @@
-from unittest.mock import patch
-
-import graphene
-
-from .....core.exceptions import PreorderAllocationError
-from .....product.error_codes import ProductErrorCode
-from .....warehouse.models import Allocation
-from ....tests.utils import assert_no_permission, get_graphql_content
-
-QUERY_VARIANT_DEACTIVATE_PREORDER = """
- mutation deactivatePreorder (
- $id: ID!
- ) {
- productVariantPreorderDeactivate(id: $id) {
- productVariant {
- sku
- preorder {
- globalThreshold
- endDate
- }
- stocks {
- quantityAllocated
- }
- }
- errors {
- field
- code
- message
- }
- }
- }
-"""
-
-
-@patch("saleor.plugins.manager.PluginsManager.product_variant_updated")
-def test_product_variant_deactivate_preorder(
- updated_webhook_mock,
- staff_api_client,
- permission_manage_products,
- preorder_variant_global_and_channel_threshold,
- preorder_allocation,
-):
- variant = preorder_variant_global_and_channel_threshold
- variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)
-
- allocations_before = Allocation.objects.filter(
- stock__product_variant_id=variant.pk
- ).count()
-
- response = staff_api_client.post_graphql(
- QUERY_VARIANT_DEACTIVATE_PREORDER,
- {"id": variant_id},
- permissions=[permission_manage_products],
- )
- variant.refresh_from_db()
- content = get_graphql_content(response)
- data = content["data"]["productVariantPreorderDeactivate"]["productVariant"]
-
- assert not data["preorder"]
- assert data["stocks"][0]["quantityAllocated"] > allocations_before
-
- updated_webhook_mock.assert_called_once_with(variant)
-
-
-def test_product_variant_deactivate_preorder_non_preorder_variant(
- staff_api_client,
- permission_manage_products,
- variant,
-):
- assert variant.is_preorder is False
- variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)
-
- response = staff_api_client.post_graphql(
- QUERY_VARIANT_DEACTIVATE_PREORDER,
- {"id": variant_id},
- permissions=[permission_manage_products],
- )
- content = get_graphql_content(response)
- error = content["data"]["productVariantPreorderDeactivate"]["errors"][0]
-
- assert error["field"] == "id"
- assert error["code"] == ProductErrorCode.INVALID.name
-
-
-@patch(
- "saleor.graphql.product.mutations.product_variant"
- ".product_variant_preorder_deactivate.deactivate_preorder_for_variant"
-)
-def test_product_variant_deactivate_preorder_cannot_deactivate(
- mock_deactivate_preorder_for_variant,
- staff_api_client,
- permission_manage_products,
- preorder_variant_global_and_channel_threshold,
- preorder_allocation,
-):
- variant = preorder_variant_global_and_channel_threshold
- variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)
-
- mock_deactivate_preorder_for_variant.side_effect = PreorderAllocationError(
- preorder_allocation.order_line
- )
-
- response = staff_api_client.post_graphql(
- QUERY_VARIANT_DEACTIVATE_PREORDER,
- {"id": variant_id},
- permissions=[permission_manage_products],
- )
- content = get_graphql_content(response)
- error = content["data"]["productVariantPreorderDeactivate"]["errors"][0]
-
- assert error["field"] is None
- assert error["code"] == ProductErrorCode.PREORDER_VARIANT_CANNOT_BE_DEACTIVATED.name
-
-
-def test_product_variant_deactivate_preorder_as_customer(
- user_api_client,
- preorder_variant_global_and_channel_threshold,
-):
- variant = preorder_variant_global_and_channel_threshold
- variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)
-
- response = user_api_client.post_graphql(
- QUERY_VARIANT_DEACTIVATE_PREORDER,
- {"id": variant_id},
- )
-
- assert_no_permission(response)
-
-
-def test_product_variant_deactivate_preorder_as_anonymous(
- api_client,
- preorder_variant_global_and_channel_threshold,
-):
- variant = preorder_variant_global_and_channel_threshold
- variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)
-
- response = api_client.post_graphql(
- QUERY_VARIANT_DEACTIVATE_PREORDER,
- {"id": variant_id},
- )
-
- assert_no_permission(response)
-
-
-def test_product_variant_deactivate_preorder_as_app_with_permission(
- app_api_client,
- preorder_variant_global_and_channel_threshold,
- permission_manage_products,
-):
- variant = preorder_variant_global_and_channel_threshold
- variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)
-
- response = app_api_client.post_graphql(
- QUERY_VARIANT_DEACTIVATE_PREORDER,
- {"id": variant_id},
- permissions=[permission_manage_products],
- )
-
- content = get_graphql_content(response)
- data = content["data"]["productVariantPreorderDeactivate"]["productVariant"]
- assert not data["preorder"]
-
-
-def test_product_variant_deactivate_preorder_as_app(
- app_api_client,
- preorder_variant_global_and_channel_threshold,
-):
- variant = preorder_variant_global_and_channel_threshold
- variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)
-
- response = app_api_client.post_graphql(
- QUERY_VARIANT_DEACTIVATE_PREORDER,
- {"id": variant_id},
- )
-
- assert_no_permission(response)
diff --git a/saleor/graphql/product/tests/mutations/test_product_variant_update.py b/saleor/graphql/product/tests/mutations/test_product_variant_update.py
index c9437f374c..e95688dd1d 100644
--- a/saleor/graphql/product/tests/mutations/test_product_variant_update.py
+++ b/saleor/graphql/product/tests/mutations/test_product_variant_update.py
@@ -3543,95 +3543,6 @@ def test_update_product_variant_name(
assert data["productVariant"]["name"] == new_name
-QUERY_UPDATE_VARIANT_PREORDER = """
- mutation updateVariant (
- $id: ID!,
- $sku: String!,
- $preorder: PreorderSettingsInput) {
- productVariantUpdate(
- id: $id,
- input: {
- sku: $sku,
- preorder: $preorder,
- }) {
- productVariant {
- sku
- preorder {
- globalThreshold
- endDate
- }
- }
- }
- }
-"""
-
-
-def test_update_product_variant_change_preorder_data(
- staff_api_client,
- permission_manage_products,
- preorder_variant_global_threshold,
-):
- variant = preorder_variant_global_threshold
- variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)
- sku = "test sku"
-
- new_global_threshold = variant.preorder_global_threshold + 5
- assert variant.preorder_end_date is None
- new_preorder_end_date = (
- (datetime.datetime.now(tz=datetime.UTC) + datetime.timedelta(days=3))
- .astimezone()
- .replace(microsecond=0)
- .isoformat()
- )
- variables = {
- "id": variant_id,
- "sku": sku,
- "preorder": {
- "globalThreshold": new_global_threshold,
- "endDate": new_preorder_end_date,
- },
- }
-
- response = staff_api_client.post_graphql(
- QUERY_UPDATE_VARIANT_PREORDER,
- variables,
- permissions=[permission_manage_products],
- )
- variant.refresh_from_db()
- content = get_graphql_content(response)
- data = content["data"]["productVariantUpdate"]["productVariant"]
-
- assert data["sku"] == sku
- assert data["preorder"]["globalThreshold"] == new_global_threshold
- assert data["preorder"]["endDate"] == new_preorder_end_date
-
-
-def test_update_product_variant_can_not_turn_off_preorder(
- staff_api_client,
- permission_manage_products,
- preorder_variant_global_threshold,
-):
- """Test that preorder cannot be disabled through updating the `preorder` field directly."""
- variant = preorder_variant_global_threshold
- variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)
- sku = "test sku"
-
- variables = {"id": variant_id, "sku": sku, "preorder": None}
-
- response = staff_api_client.post_graphql(
- QUERY_UPDATE_VARIANT_PREORDER,
- variables,
- permissions=[permission_manage_products],
- )
- variant.refresh_from_db()
- content = get_graphql_content(response)
- data = content["data"]["productVariantUpdate"]["productVariant"]
-
- assert data["sku"] == sku
- assert data["preorder"]["globalThreshold"] == variant.preorder_global_threshold
- assert data["preorder"]["endDate"] is None
-
-
# Query used to check how Product Variant metadata updates behaves
# and which events are emitted
UPDATE_METADATA_QUERY = """
@@ -4006,9 +3917,6 @@ def test_update_product_variant_nothing_changed(
value = "some_value"
variant.metadata = {key: value}
variant.private_metadata = {key: value}
- variant.is_preorder = True
- variant.preorder_global_threshold = 10
- variant.preorder_end_date = "2024-12-02T00:00Z"
variant.track_inventory = True
variant.weight = Weight(kg=10)
variant.quantity_limit_per_customer = 10
@@ -4034,10 +3942,6 @@ def test_update_product_variant_nothing_changed(
"name": variant.name,
"trackInventory": variant.track_inventory,
"weight": 10,
- "preorder": {
- "globalThreshold": variant.preorder_global_threshold,
- "endDate": variant.preorder_end_date,
- },
"quantityLimitPerCustomer": variant.quantity_limit_per_customer,
"metadata": [{"key": key, "value": value}],
"privateMetadata": [{"key": key, "value": value}],
@@ -4088,9 +3992,6 @@ def test_update_product_variant_emit_event(
value = "some_value"
variant.metadata = {key: value}
variant.private_metadata = {key: value}
- variant.is_preorder = True
- variant.preorder_global_threshold = 10
- variant.preorder_end_date = "2024-12-02T00:00Z"
variant.track_inventory = True
variant.weight = Weight(kg=10)
variant.quantity_limit_per_customer = 10
@@ -4113,10 +4014,6 @@ def test_update_product_variant_emit_event(
"name": variant.name + "_new",
"trackInventory": not variant.track_inventory,
"weight": 11,
- "preorder": {
- "globalThreshold": variant.preorder_global_threshold + 1,
- "endDate": "2024-12-03T00:00Z",
- },
"quantityLimitPerCustomer": variant.quantity_limit_per_customer + 1,
"metadata": [{"key": key + "_new", "value": value + "_new"}],
"privateMetadata": [{"key": key + "_new", "value": value + "_new"}],
diff --git a/saleor/graphql/product/tests/queries/test_product_variant_query.py b/saleor/graphql/product/tests/queries/test_product_variant_query.py
index b0d73421cc..2c01a6f1e6 100644
--- a/saleor/graphql/product/tests/queries/test_product_variant_query.py
+++ b/saleor/graphql/product/tests/queries/test_product_variant_query.py
@@ -220,10 +220,6 @@ QUERY_PRODUCT_VARIANT_CHANNEL_LISTING = """
currency
amount
}
- preorderThreshold {
- quantity
- soldUnits
- }
}
}
}
@@ -261,10 +257,6 @@ def test_get_product_variant_channel_listing_as_staff_user(
"currency": channel_listing.currency,
"amount": channel_listing.cost_price_amount,
},
- "preorderThreshold": {
- "quantity": channel_listing.preorder_quantity_threshold,
- "soldUnits": 0,
- },
} in data["channelListings"]
assert len(data["channelListings"]) == variant.channel_listings.count()
@@ -300,10 +292,6 @@ def test_get_product_variant_channel_listing_as_app(
"currency": channel_listing.currency,
"amount": channel_listing.cost_price_amount,
},
- "preorderThreshold": {
- "quantity": channel_listing.preorder_quantity_threshold,
- "soldUnits": 0,
- },
} in data["channelListings"]
assert len(data["channelListings"]) == variant.channel_listings.count()
@@ -455,98 +443,6 @@ def test_get_product_variant_stocks_no_channel_shipping_zones(
assert stocks_count > 0
-QUERY_PRODUCT_VARIANT_PREORDER = """
- query ProductVariantDetails($id: ID!, $channel: String) {
- productVariant(id: $id, channel: $channel) {
- preorder {
- globalThreshold
- globalSoldUnits
- endDate
- }
- }
- }
-"""
-
-
-def test_get_product_variant_preorder_as_staff(
- staff_api_client,
- preorder_variant_global_and_channel_threshold,
- preorder_allocation,
- channel_USD,
- permission_manage_products,
-):
- # given
- variant = preorder_variant_global_and_channel_threshold
- variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)
- variables = {"id": variant_id, "channel": channel_USD.slug}
-
- # when
- response = staff_api_client.post_graphql(
- QUERY_PRODUCT_VARIANT_PREORDER,
- variables,
- permissions=[permission_manage_products],
- check_no_permissions=False,
- )
- content = get_graphql_content(response)
-
- # then
- data = content["data"]["productVariant"]["preorder"]
- assert data["globalThreshold"] == variant.preorder_global_threshold
- assert data["globalSoldUnits"] == preorder_allocation.quantity
- assert data["endDate"] == variant.preorder_end_date
-
-
-def test_get_product_variant_preorder_as_customer_not_allowed_fields(
- user_api_client,
- preorder_variant_global_threshold,
- channel_USD,
-):
- # given
- variant = preorder_variant_global_threshold
- variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)
- variables = {"id": variant_id, "channel": channel_USD.slug}
-
- # when
- response = user_api_client.post_graphql(
- QUERY_PRODUCT_VARIANT_PREORDER,
- variables,
- )
-
- # then
- assert_no_permission(response)
-
-
-def test_get_product_variant_preorder_as_customer_allowed_fields(
- user_api_client,
- preorder_variant_global_threshold,
- channel_USD,
-):
- # given
- variant = preorder_variant_global_threshold
- variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)
- query = """
- query ProductVariantDetails($id: ID!, $channel: String) {
- productVariant(id: $id, channel: $channel) {
- preorder {
- endDate
- }
- }
- }
- """
- variables = {"id": variant_id, "channel": channel_USD.slug}
-
- # when
- response = user_api_client.post_graphql(
- query,
- variables,
- )
- content = get_graphql_content(response)
-
- # then
- data = content["data"]["productVariant"]["preorder"]
- assert data["endDate"] == variant.preorder_end_date
-
-
def _fetch_variant(client, variant, channel_slug=None, permissions=None):
query = """
query ProductVariantDetails($variantId: ID!, $channel: String) {
diff --git a/saleor/graphql/product/tests/queries/test_products_query_with_filter.py b/saleor/graphql/product/tests/queries/test_products_query_with_filter.py
index 055f4fb449..45ee7ba983 100644
--- a/saleor/graphql/product/tests/queries/test_products_query_with_filter.py
+++ b/saleor/graphql/product/tests/queries/test_products_query_with_filter.py
@@ -1975,101 +1975,3 @@ def test_query_products_with_filter_ids(api_client, product_list, channel_USD):
assert len(products_data) == 2
assert [node["node"]["id"] for node in products_data] == product_ids
-
-
-def test_products_query_with_filter_has_preordered_variants_false(
- staff_api_client,
- preorder_variant_global_threshold,
- product_without_shipping,
- permission_manage_products,
-):
- # given
- product = product_without_shipping
- variables = {"filter": {"hasPreorderedVariants": False}}
- staff_api_client.user.user_permissions.add(permission_manage_products)
-
- # when
- response = staff_api_client.post_graphql(QUERY_PRODUCTS_WITH_FILTER, variables)
- content = get_graphql_content(response)
-
- # then
- product_id = graphene.Node.to_global_id("Product", product.id)
- products = content["data"]["products"]["edges"]
-
- assert len(products) == 1
- assert products[0]["node"]["id"] == product_id
- assert products[0]["node"]["name"] == product.name
-
-
-def test_products_query_with_filter_has_preordered_variants_true(
- staff_api_client,
- preorder_variant_global_threshold,
- product_without_shipping,
- permission_manage_products,
-):
- # given
- product = preorder_variant_global_threshold.product
- variables = {"filter": {"hasPreorderedVariants": True}}
- staff_api_client.user.user_permissions.add(permission_manage_products)
-
- # when
- response = staff_api_client.post_graphql(QUERY_PRODUCTS_WITH_FILTER, variables)
- content = get_graphql_content(response)
-
- # then
- product_id = graphene.Node.to_global_id("Product", product.id)
- products = content["data"]["products"]["edges"]
-
- assert len(products) == 1
- assert products[0]["node"]["id"] == product_id
- assert products[0]["node"]["name"] == product.name
-
-
-def test_products_query_with_filter_has_preordered_variants_before_end_date(
- staff_api_client,
- preorder_variant_global_threshold,
- permission_manage_products,
-):
- # given
- variant = preorder_variant_global_threshold
- variant.preorder_end_date = timezone.now() + datetime.timedelta(days=3)
- variant.save(update_fields=["preorder_end_date"])
-
- product = preorder_variant_global_threshold.product
- variables = {"filter": {"hasPreorderedVariants": True}}
- staff_api_client.user.user_permissions.add(permission_manage_products)
-
- # when
- response = staff_api_client.post_graphql(QUERY_PRODUCTS_WITH_FILTER, variables)
- content = get_graphql_content(response)
-
- # then
- product_id = graphene.Node.to_global_id("Product", product.id)
- products = content["data"]["products"]["edges"]
-
- assert len(products) == 1
- assert products[0]["node"]["id"] == product_id
- assert products[0]["node"]["name"] == product.name
-
-
-def test_products_query_with_filter_has_preordered_variants_after_end_date(
- staff_api_client,
- preorder_variant_global_threshold,
- permission_manage_products,
-):
- # given
- variant = preorder_variant_global_threshold
- variant.preorder_end_date = timezone.now() - datetime.timedelta(days=3)
- variant.save(update_fields=["preorder_end_date"])
-
- variables = {"filter": {"hasPreorderedVariants": True}}
- staff_api_client.user.user_permissions.add(permission_manage_products)
-
- # when
- response = staff_api_client.post_graphql(QUERY_PRODUCTS_WITH_FILTER, variables)
- content = get_graphql_content(response)
-
- # then
- products = content["data"]["products"]["edges"]
-
- assert len(products) == 0
diff --git a/saleor/graphql/product/tests/queries/test_products_query_with_where.py b/saleor/graphql/product/tests/queries/test_products_query_with_where.py
index 3837683508..5eceb482a3 100644
--- a/saleor/graphql/product/tests/queries/test_products_query_with_where.py
+++ b/saleor/graphql/product/tests/queries/test_products_query_with_where.py
@@ -1820,98 +1820,6 @@ def test_products_filter_by_none_as_gift_card(
assert len(products) == 0
[email protected](("filter", "index"), [(False, 0), (True, 1)])
-def test_products_query_with_filter_has_preordered_variants(
- filter,
- index,
- api_client,
- preorder_variant_global_threshold,
- product_without_shipping,
- channel_USD,
-):
- # given
- product_list = [product_without_shipping, preorder_variant_global_threshold.product]
- variables = {
- "channel": channel_USD.slug,
- "where": {"hasPreorderedVariants": filter},
- }
-
- # when
- response = api_client.post_graphql(PRODUCTS_WHERE_QUERY, variables)
- content = get_graphql_content(response)
-
- # then
- product_id = graphene.Node.to_global_id("Product", product_list[index].id)
- products = content["data"]["products"]["edges"]
-
- assert len(products) == 1
- assert products[0]["node"]["id"] == product_id
-
-
-def test_products_query_with_filter_none_as_has_preordered_variants(
- api_client,
- preorder_variant_global_threshold,
- product_without_shipping,
- channel_USD,
-):
- # given
- variables = {
- "channel": channel_USD.slug,
- "where": {"hasPreorderedVariants": None},
- }
-
- # when
- response = api_client.post_graphql(PRODUCTS_WHERE_QUERY, variables)
- content = get_graphql_content(response)
-
- # then
- products = content["data"]["products"]["edges"]
- assert len(products) == 0
-
-
-def test_products_filter_by_has_preordered_variants_before_end_date(
- api_client, preorder_variant_global_threshold, channel_USD
-):
- # given
- variant = preorder_variant_global_threshold
- variant.preorder_end_date = timezone.now() + datetime.timedelta(days=3)
- variant.save(update_fields=["preorder_end_date"])
-
- product = preorder_variant_global_threshold.product
- variables = {"channel": channel_USD.slug, "where": {"hasPreorderedVariants": True}}
-
- # when
- response = api_client.post_graphql(PRODUCTS_WHERE_QUERY, variables)
- content = get_graphql_content(response)
-
- # then
- product_id = graphene.Node.to_global_id("Product", product.id)
- products = content["data"]["products"]["edges"]
-
- assert len(products) == 1
- assert products[0]["node"]["id"] == product_id
-
-
-def test_products_filter_by_has_preordered_variants_after_end_date(
- api_client, preorder_variant_global_threshold, channel_USD
-):
- # given
- variant = preorder_variant_global_threshold
- variant.preorder_end_date = timezone.now() - datetime.timedelta(days=3)
- variant.save(update_fields=["preorder_end_date"])
-
- variables = {"channel": channel_USD.slug, "where": {"hasPreorderedVariants": True}}
-
- # when
- response = api_client.post_graphql(PRODUCTS_WHERE_QUERY, variables)
- content = get_graphql_content(response)
-
- # then
- products = content["data"]["products"]["edges"]
-
- assert len(products) == 0
-
-
def test_product_filter_by_updated_at(api_client, product_list, channel_USD):
# given
timestamp = timezone.now()
diff --git a/saleor/graphql/product/tests/test_variant_channel_listing_update.py b/saleor/graphql/product/tests/test_variant_channel_listing_update.py
index 75b0d30d71..9d1dba639a 100644
--- a/saleor/graphql/product/tests/test_variant_channel_listing_update.py
+++ b/saleor/graphql/product/tests/test_variant_channel_listing_update.py
@@ -45,9 +45,6 @@ mutation UpdateProductVariantChannelListing(
currency
}
margin
- preorderThreshold {
- quantity
- }
}
}
}
@@ -556,74 +553,6 @@ def test_product_channel_listing_update_invalid_cost_price(
assert_negative_positive_decimal_value(response)
-def test_variant_channel_listing_update_preorder(
- staff_api_client, product, permission_manage_products, channel_USD, channel_PLN
-):
- # given
- ProductChannelListing.objects.create(
- product=product,
- channel=channel_PLN,
- is_published=True,
- )
- variant = product.variants.get()
- variant.is_preorder = True
- variant.save(update_fields=["is_preorder"])
- variant_id = graphene.Node.to_global_id("ProductVariant", variant.id)
- channel_usd_id = graphene.Node.to_global_id("Channel", channel_USD.id)
- channel_pln_id = graphene.Node.to_global_id("Channel", channel_PLN.id)
- preorder_threshold_channel_usd = 10
- preorder_threshold_channel_pln = 20
- variables = {
- "id": variant_id,
- "input": [
- {
- "channelId": channel_usd_id,
- "price": 1,
- "preorderThreshold": preorder_threshold_channel_usd,
- },
- {
- "channelId": channel_pln_id,
- "price": 20,
- "preorderThreshold": preorder_threshold_channel_pln,
- },
- ],
- }
-
- # when
- response = staff_api_client.post_graphql(
- PRODUCT_VARIANT_CHANNEL_LISTING_UPDATE_MUTATION,
- variables=variables,
- permissions=(permission_manage_products,),
- )
- content = get_graphql_content(response)
-
- # then
- data = content["data"]["productVariantChannelListingUpdate"]
- variant_data = data["variant"]
- assert not data["errors"]
- assert variant_data["id"] == variant_id
- channel_usd_data = next(
- channel_data
- for channel_data in variant_data["channelListings"]
- if channel_data["channel"]["id"] == channel_usd_id
- )
- channel_pln_data = next(
- channel_data
- for channel_data in variant_data["channelListings"]
- if channel_data["channel"]["id"] == channel_pln_id
- )
- assert channel_usd_data["channel"]["slug"] == channel_USD.slug
- assert (
- channel_usd_data["preorderThreshold"]["quantity"]
- == preorder_threshold_channel_usd
- )
- assert channel_pln_data["channel"]["slug"] == channel_PLN.slug
- assert (
- channel_pln_data["preorderThreshold"]["quantity"]
- == preorder_threshold_channel_pln
- )
-
-
@pytest.mark.parametrize("prior_price", [1.5, 0])
def test_variant_channel_listing_update_with_prior_price(
staff_api_client, product, permission_manage_products, channel_USD, prior_price
diff --git a/saleor/graphql/product/tests/test_variant_with_filtering.py b/saleor/graphql/product/tests/test_variant_with_filtering.py
index b35647723a..b371be0a3c 100644
--- a/saleor/graphql/product/tests/test_variant_with_filtering.py
+++ b/saleor/graphql/product/tests/test_variant_with_filtering.py
@@ -1,7 +1,4 @@
-import datetime
-
import pytest
-from django.utils import timezone
from freezegun import freeze_time
from ....product.models import Product, ProductVariant
@@ -62,12 +59,6 @@ def products_for_variant_filtering(product_type, category):
category=category,
product_type=product_type,
),
- Product(
- name="ProductWithPreorder",
- slug="prod5",
- category=category,
- product_type=product_type,
- ),
]
)
ProductVariant.objects.bulk_create(
@@ -97,23 +88,6 @@ def products_for_variant_filtering(product_type, category):
ProductVariant(
product=products[5],
),
- ProductVariant(
- product=products[6],
- sku="Preorder-V1",
- is_preorder=True,
- ),
- ProductVariant(
- product=products[6],
- sku="Preorder-V2",
- is_preorder=True,
- preorder_end_date=timezone.now() + datetime.timedelta(days=1),
- ),
- ProductVariant(
- product=products[6],
- sku="Preorder-V3",
- is_preorder=True,
- preorder_end_date=timezone.now() - datetime.timedelta(days=1),
- ),
]
)
update_products_search_vector([product.id for product in products])
@@ -135,21 +109,6 @@ def products_for_variant_filtering(product_type, category):
({"sku": ["P1-V1", "P1-V2", "PP1-V1"]}, ["P1-V1", "P1-V2", "PP1-V1"]),
({"sku": ["PP1-V1", "PP2-V1"]}, ["PP1-V1", "PP2-V1"]),
({"sku": ["invalid"]}, []),
- ({"isPreorder": True}, ["Preorder-V1", "Preorder-V2"]),
- (
- {"isPreorder": False},
- [
- "P-NO-SKU",
- "P1-V1",
- "P1-V2",
- "P2-V1",
- "P3-V1",
- "PP1-V1",
- "PP2-V1",
- "Preorder-V3",
- None,
- ],
- ),
],
)
def test_products_pagination_with_filtering(
diff --git a/saleor/graphql/product/types/channels.py b/saleor/graphql/product/types/channels.py
index 648b225ff2..5931dfdb15 100644
--- a/saleor/graphql/product/types/channels.py
+++ b/saleor/graphql/product/types/channels.py
@@ -21,10 +21,6 @@ from ....tax.utils import (
from ...account import types as account_types
from ...channel.dataloaders.by_self import ChannelByIdLoader
from ...channel.types import Channel
-from ...core.descriptions import (
- DEPRECATED_PREORDER,
- DEPRECATED_PREORDER_TYPE_DESCRIPTION,
-)
from ...core.doc_category import DOC_CATEGORY_PRODUCTS
from ...core.fields import PermissionsField
from ...core.scalars import Date, DateTime
@@ -293,26 +289,6 @@ class ProductChannelListing(ModelObjectType[models.ProductChannelListing]):
return Promise.all([channel, tax_class_id_loader]).then(load_tax_configuration)
-class PreorderThreshold(BaseObjectType):
- quantity = graphene.Int(
- required=False,
- description="Preorder threshold for product variant in this channel.",
- deprecation_reason=DEPRECATED_PREORDER,
- )
- sold_units = graphene.Int(
- required=True,
- description="Number of sold product variant in this channel.",
- deprecation_reason=DEPRECATED_PREORDER,
- )
-
- class Meta:
- doc_category = DOC_CATEGORY_PRODUCTS
- description = (
- "Represents preorder variant data for channel."
- + DEPRECATED_PREORDER_TYPE_DESCRIPTION
- )
-
-
class ProductVariantChannelListing(
ModelObjectType[models.ProductVariantChannelListing]
):
@@ -337,12 +313,6 @@ class ProductVariantChannelListing(
description="Gross margin percentage value.",
permissions=[ProductPermissions.MANAGE_PRODUCTS],
)
- preorder_threshold = graphene.Field(
- PreorderThreshold,
- required=False,
- description="Preorder variant data.",
- deprecation_reason=DEPRECATED_PREORDER,
- )
class Meta:
description = "Represents product variant channel listing."
@@ -357,15 +327,6 @@ class ProductVariantChannelListing(
def resolve_margin(root: models.ProductVariantChannelListing, _info):
return get_margin_for_variant_channel_listing(root)
- @staticmethod
- def resolve_preorder_threshold(root: models.ProductVariantChannelListing, _info):
- # The preorder_quantity_allocated field is added through annotation
- # when using the `resolve_channel_listings` resolver.
- return PreorderThreshold(
- quantity=root.preorder_quantity_threshold,
- sold_units=getattr(root, "preorder_quantity_allocated", 0),
- )
-
class CollectionChannelListing(ModelObjectType[models.CollectionChannelListing]):
id = graphene.GlobalID(
diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.py
index 60dc3ee102..4d2d2decfc 100644
--- a/saleor/graphql/product/types/products.py
+++ b/saleor/graphql/product/types/products.py
@@ -68,8 +68,6 @@ from ...core.context import (
from ...core.descriptions import (
ADDED_IN_322,
DEPRECATED_IN_3X_INPUT,
- DEPRECATED_PREORDER,
- DEPRECATED_PREORDER_TYPE_DESCRIPTION,
RICH_CONTENT,
)
from ...core.doc_category import DOC_CATEGORY_PRODUCTS
@@ -277,43 +275,6 @@ class ProductPricingInfo(BasePricingInfo):
description = "Represents availability of a product in the storefront."
-class PreorderData(BaseObjectType):
- global_threshold = PermissionsField(
- graphene.Int,
- required=False,
- description="The global preorder threshold for product variant.",
- permissions=[ProductPermissions.MANAGE_PRODUCTS],
- deprecation_reason=DEPRECATED_PREORDER,
- )
- global_sold_units = PermissionsField(
- graphene.Int,
- required=True,
- description="Total number of sold product variant during preorder.",
- permissions=[ProductPermissions.MANAGE_PRODUCTS],
- deprecation_reason=DEPRECATED_PREORDER,
- )
- end_date = DateTime(
- required=False,
- description="Preorder end date.",
- deprecation_reason=DEPRECATED_PREORDER,
- )
-
- class Meta:
- doc_category = DOC_CATEGORY_PRODUCTS
- description = (
- "Represents preorder settings for product variant."
- + DEPRECATED_PREORDER_TYPE_DESCRIPTION
- )
-
- @staticmethod
- def resolve_global_threshold(root, _info):
- return root.global_threshold
-
- @staticmethod
- def resolve_global_sold_units(root, _info):
- return root.global_sold_units
-
-
@federated_entity("id channel")
class ProductVariant(ChannelContextType[models.ProductVariant]):
id = graphene.GlobalID(required=True, description="The ID of the product variant.")
@@ -461,12 +422,6 @@ class ProductVariant(ChannelContextType[models.ProductVariant]):
),
),
)
- preorder = graphene.Field(
- PreorderData,
- required=False,
- description="Preorder data for product variant.",
- deprecation_reason=DEPRECATED_PREORDER,
- )
created = DateTime(
required=True,
description="The date and time when the product variant was created.",
@@ -859,32 +814,6 @@ class ProductVariant(ChannelContextType[models.ProductVariant]):
def resolve_weight(root: ChannelContext[models.ProductVariant], _info):
return convert_weight_to_default_weight_unit(root.node.weight)
- @staticmethod
- @traced_resolver
- def resolve_preorder(root: ChannelContext[models.ProductVariant], info):
- variant = root.node
-
- variant_channel_listings = VariantChannelListingByVariantIdLoader(
- info.context
- ).load(variant.id)
-
- def calculate_global_sold_units(variant_channel_listings):
- global_sold_units = sum(
- channel_listing.preorder_quantity_allocated
- for channel_listing in variant_channel_listings
- )
- return (
- PreorderData(
- global_threshold=variant.preorder_global_threshold,
- global_sold_units=global_sold_units,
- end_date=variant.preorder_end_date,
- )
- if variant.is_preorder_active()
- else None
- )
-
- return variant_channel_listings.then(calculate_global_sold_units)
-
@staticmethod
def __resolve_references(roots: list["ProductVariant"], info):
requestor = get_user_or_app_from_context(info.context)
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 6615660ce5..3a8eb04182 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -4461,9 +4461,6 @@ input ProductFilterInput @doc(category: "Products") {
"""Filter on whether product is a gift card or not."""
giftCard: Boolean
ids: [ID!]
-
- """Filter by product with preordered variants."""
- hasPreorderedVariants: Boolean @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
slugs: [String!]
"""Specifies the channel by which the data should be filtered."""
@@ -4718,9 +4715,6 @@ input ProductWhereInput @doc(category: "Products") {
"""Filter on whether product is a gift card or not."""
giftCard: Boolean
- """Filter by product with preordered variants."""
- hasPreorderedVariants: Boolean @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
-
"""Filter by when was the most recent update."""
updatedAt: DateTimeFilterInput
@@ -7456,9 +7450,6 @@ type ProductVariant implements Node & ObjectWithMetadata & ObjectWithAttributes
countryCode: CountryCode @deprecated(reason: "Use `address` argument instead.")
): Int
- """Preorder data for product variant."""
- preorder: PreorderData @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
-
"""The date and time when the product variant was created."""
created: DateTime!
@@ -7496,9 +7487,6 @@ type ProductVariantChannelListing implements Node @doc(category: "Products") {
Requires one of the following permissions: MANAGE_PRODUCTS.
"""
margin: Int
-
- """Preorder variant data."""
- preorderThreshold: PreorderThreshold @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
}
"""Represents channel."""
@@ -9391,19 +9379,6 @@ type TaxConfigurationPerCountry @doc(category: "Taxes") {
useWeightedTaxForShipping: Boolean
}
-"""
-Represents preorder variant data for channel.
-
-DEPRECATED: Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.
-"""
-type PreorderThreshold @doc(category: "Products") {
- """Preorder threshold for product variant in this channel."""
- quantity: Int @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
-
- """Number of sold product variant in this channel."""
- soldUnits: Int! @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
-}
-
"""Represents availability of a variant in the storefront."""
type VariantPricingInfo @doc(category: "Products") {
"""Whether it is in sale or not."""
@@ -9831,30 +9806,6 @@ type ProductVariantTranslatableContent implements Node @doc(category: "Products"
attributeValues: [AttributeValueTranslatableContent!]!
}
-"""
-Represents preorder settings for product variant.
-
-DEPRECATED: Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.
-"""
-type PreorderData @doc(category: "Products") {
- """
- The global preorder threshold for product variant.
-
- Requires one of the following permissions: MANAGE_PRODUCTS.
- """
- globalThreshold: Int @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
-
- """
- Total number of sold product variant during preorder.
-
- Requires one of the following permissions: MANAGE_PRODUCTS.
- """
- globalSoldUnits: Int! @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
-
- """Preorder end date."""
- endDate: DateTime @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
-}
-
"""Represents availability of a product in the storefront."""
type ProductPricingInfo @doc(category: "Products") {
"""Whether it is in sale or not."""
@@ -9992,9 +9943,6 @@ input ProductVariantFilterInput @doc(category: "Products") {
search: String
sku: [String!]
metadata: [MetadataFilter!]
-
- """Filter by variants that are currently in preorder."""
- isPreorder: Boolean @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
updatedAt: DateTimeRangeInput
}
@@ -16003,9 +15951,6 @@ input OrderFilterInput @doc(category: "Orders") {
chargeStatus: [OrderChargeStatusEnum!]
updatedAt: DateTimeRangeInput
isClickAndCollect: Boolean
-
- """Filter by orders containing a variant that is currently in preorder."""
- isPreorder: Boolean @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
ids: [ID!]
checkoutTokens: [UUID!]
giftCardUsed: Boolean
@@ -18993,18 +18938,6 @@ type Mutation {
variantId: ID!
): ProductVariantReorderAttributeValues @doc(category: "Products")
- """
- Deactivates product variant preorder. It changes all preorder allocation into regular allocation.
-
- DEPRECATED: Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.
-
- Requires one of the following permissions: MANAGE_PRODUCTS.
- """
- productVariantPreorderDeactivate(
- """ID of a variant which preorder should be deactivated."""
- id: ID!
- ): ProductVariantPreorderDeactivate @doc(category: "Products") @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
-
"""
Assign an media to a product variant.
@@ -24219,7 +24152,6 @@ enum ProductErrorCode @doc(category: "Products") {
CANNOT_MANAGE_PRODUCT_WITHOUT_VARIANT
PRODUCT_NOT_ASSIGNED_TO_CHANNEL
UNSUPPORTED_MEDIA_PROVIDER
- PREORDER_VARIANT_CANNOT_BE_DEACTIVATED @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
INVALID_FILE_TYPE
UNSUPPORTED_MIME_TYPE
FILE_SIZE_LIMIT_EXCEEDED
@@ -25030,9 +24962,6 @@ input ProductVariantBulkCreateInput @doc(category: "Products") {
"""Weight of the Product Variant."""
weight: WeightScalar
- """Determines if variant is in preorder."""
- preorder: PreorderSettingsInput @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
-
"""
Determines maximum quantity of `ProductVariant`,that can be bought in a single checkout.
"""
@@ -25120,19 +25049,6 @@ input BulkAttributeValueInput @doc(category: "Products") {
dateTime: DateTime
}
-"""
-Preorder settings for a product variant.
-
-DEPRECATED: Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.
-"""
-input PreorderSettingsInput @doc(category: "Products") {
- """The global threshold for preorder variant."""
- globalThreshold: Int @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
-
- """The end date for preorder."""
- endDate: DateTime @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
-}
-
input StockInput @doc(category: "Products") {
"""Warehouse in which stock is located."""
warehouse: ID!
@@ -25155,9 +25071,6 @@ input ProductVariantChannelListingAddInput @doc(category: "Products") {
Previous price of the variant in channel. Useful for providing promotion information required by customer protection laws such as EU Omnibus directive.
"""
priorPrice: PositiveDecimal
-
- """The threshold for preorder variant in channel."""
- preorderThreshold: Int @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
}
"""
@@ -25636,9 +25549,6 @@ input ProductVariantCreateInput @doc(category: "Products") {
"""Weight of the Product Variant."""
weight: WeightScalar
- """Determines if variant is in preorder."""
- preorder: PreorderSettingsInput @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
-
"""
Determines maximum quantity of `ProductVariant`,that can be bought in a single checkout.
"""
@@ -25818,9 +25728,6 @@ input ProductVariantBulkUpdateInput @doc(category: "Products") {
"""Weight of the Product Variant."""
weight: WeightScalar
- """Determines if variant is in preorder."""
- preorder: PreorderSettingsInput @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
-
"""
Determines maximum quantity of `ProductVariant`,that can be bought in a single checkout.
"""
@@ -25895,9 +25802,6 @@ input ChannelListingUpdateInput @doc(category: "Products") {
"""Price of the variant before discount."""
priorPrice: PositiveDecimal
-
- """The threshold for preorder variant in channel."""
- preorderThreshold: Int @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
}
"""
@@ -26056,9 +25960,6 @@ input ProductVariantInput @doc(category: "Products") {
"""Weight of the Product Variant."""
weight: WeightScalar
- """Determines if variant is in preorder."""
- preorder: PreorderSettingsInput @deprecated(reason: "Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.")
-
"""
Determines maximum quantity of `ProductVariant`,that can be bought in a single checkout.
"""
@@ -26192,19 +26093,6 @@ type ProductVariantReorderAttributeValues @doc(category: "Products") {
errors: [ProductError!]!
}
-"""
-Deactivates product variant preorder. It changes all preorder allocation into regular allocation.
-
-DEPRECATED: Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set `trackInventory` to false to sell without a stock limit.
-
-Requires one of the following permissions: MANAGE_PRODUCTS.
-"""
-type ProductVariantPreorderDeactivate @doc(category: "Products") {
- """Product variant with ended preorder."""
- productVariant: ProductVariant
- errors: [ProductError!]!
-}
-
"""
Assign an media to a product variant.
diff --git a/saleor/order/tests/fixtures/order.py b/saleor/order/tests/fixtures/order.py
index 85fe453235..ba810d0f82 100644
--- a/saleor/order/tests/fixtures/order.py
+++ b/saleor/order/tests/fixtures/order.py
@@ -1,11 +1,9 @@
import datetime
-from datetime import timedelta
from decimal import Decimal
import graphene
import pytest
from django.utils import timezone
-from freezegun import freeze_time
from prices import Money, TaxedMoney
from ....checkout.utils import get_prices_of_discounted_specific_product
@@ -1110,47 +1108,3 @@ def order_without_shipping_required(order, product_without_shipping):
Allocation.objects.create(order_line=line, stock=stock, quantity_allocated=quantity)
return order
-
-
-@freeze_time("2021-11-01 12:00:01")
-def preorders(orders, product):
- variants = [
- ProductVariant(
- product=product,
- is_preorder=True,
- sku=f"Preorder product variant #{i + 1}",
- )
- for i in range(4)
- ]
- variants[1].preorder_end_date = timezone.now() + timedelta(days=1)
- variants[2].preorder_end_date = timezone.now()
- variants[3].preorder_end_date = timezone.now() - timedelta(days=1)
- ProductVariant.objects.bulk_create(variants)
-
- lines = [
- OrderLine(
- order=order,
- product_name=str(product),
- variant_name=str(variant),
- product_sku=variant.sku,
- product_variant_id=variant.get_global_id(),
- is_shipping_required=variant.is_shipping_required(),
- is_gift_card=variant.is_gift_card(),
- quantity=1,
- variant=variant,
- unit_price_net_amount=Decimal("10.0"),
- unit_price_gross_amount=Decimal("10.0"),
- currency="USD",
- total_price_net_amount=Decimal("10.0"),
- total_price_gross_amount=Decimal("10.0"),
- undiscounted_unit_price_net_amount=Decimal("10.0"),
- undiscounted_unit_price_gross_amount=Decimal("10.0"),
- undiscounted_total_price_net_amount=Decimal("10.0"),
- undiscounted_total_price_gross_amount=Decimal("10.0"),
- )
- for variant, order in zip(variants, orders, strict=False)
- ]
- OrderLine.objects.bulk_create(lines)
- preorders = orders[: len(variants) - 1]
- return preorders
diff --git a/saleor/product/error_codes.py b/saleor/product/error_codes.py
index 4b0fab6ef8..e09662afa1 100644
--- a/saleor/product/error_codes.py
+++ b/saleor/product/error_codes.py
@@ -20,7 +20,6 @@ class ProductErrorCode(Enum):
CANNOT_MANAGE_PRODUCT_WITHOUT_VARIANT = "cannot_manage_product_without_variant"
PRODUCT_NOT_ASSIGNED_TO_CHANNEL = "product_not_assigned_to_channel"
UNSUPPORTED_MEDIA_PROVIDER = "unsupported_media_provider"
- PREORDER_VARIANT_CANNOT_BE_DEACTIVATED = "preorder_variant_cannot_be_deactivated"
INVALID_FILE_TYPE = "invalid_file_type"
UNSUPPORTED_MIME_TYPE = "unsupported_mime_type"
FILE_SIZE_LIMIT_EXCEEDED = "file_size_limit_exceeded"
diff --git a/saleor/product/models.py b/saleor/product/models.py
index 6bcd11c2a8..c956fa5d3e 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -357,6 +357,7 @@ class ProductVariant(SortableModel, ModelWithMetadata, ModelWithExternalReferenc
"product.ProductMedia", through="product.VariantMedia"
)
track_inventory = models.BooleanField(default=True)
+ # TODO remove after 3.24: preorder API was removed in 3.24
is_preorder = models.BooleanField(default=False)
preorder_end_date = models.DateTimeField(null=True, blank=True)
preorder_global_threshold = models.IntegerField(blank=True, null=True)
@@ -534,6 +535,7 @@ class ProductVariantChannelListing(models.Model):
blank=True,
)
+ # TODO remove after 3.24: preorder API was removed in 3.24
preorder_quantity_threshold = models.IntegerField(blank=True, null=True)
objects = managers.ProductVariantChannelListingManager()
diff --git a/saleor/warehouse/models.py b/saleor/warehouse/models.py
index 5adb20cf15..7a5ee4ef02 100644
--- a/saleor/warehouse/models.py
+++ b/saleor/warehouse/models.py
@@ -595,6 +595,8 @@ class Allocation(models.Model):
class PreorderAllocation(models.Model):
+ """TODO remove after 3.24: preorder API was removed in 3.24."""
+
order_line = models.ForeignKey(
OrderLine,
null=False,
@@ -634,6 +636,8 @@ ReservationManager = models.Manager.from_queryset(ReservationQuerySet)
class PreorderReservation(models.Model):
+ """TODO remove after 3.24: preorder API was removed in 3.24."""
+
checkout_line = models.ForeignKey(
CheckoutLine,
null=False,