Skip to content

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

Update VoucherInput (#14525)

Iga Karbowiakb7f3deb08f40
diff --git a/saleor/checkout/tests/test_checkout_complete.py b/saleor/checkout/tests/test_checkout_complete.py
index a17494b84d..58e5cdcf4a 100644
--- a/saleor/checkout/tests/test_checkout_complete.py
+++ b/saleor/checkout/tests/test_checkout_complete.py
@@ -1844,7 +1844,8 @@ def test_complete_checkout_invalid_shipping_method(
checkout.tracking_code = ""
checkout.redirect_url = "https://www.example.com"
- checkout.voucher_code = voucher.code
+ voucher_code = voucher.codes.first()
+ checkout.voucher_code = voucher_code.code
checkout.save()
# make the current shipping method invalid
@@ -1870,7 +1871,7 @@ def test_complete_checkout_invalid_shipping_method(
# then
voucher_customer = VoucherCustomer.objects.filter(
- voucher=voucher, customer_email=customer_user.email
+ voucher_code=voucher_code, customer_email=customer_user.email
)
assert not voucher_customer.exists()
diff --git a/saleor/graphql/discount/mutations/voucher/voucher_create.py b/saleor/graphql/discount/mutations/voucher/voucher_create.py
index c5228d83b2..413bd86379 100644
--- a/saleor/graphql/discount/mutations/voucher/voucher_create.py
+++ b/saleor/graphql/discount/mutations/voucher/voucher_create.py
@@ -34,7 +34,10 @@ class VoucherInput(BaseInputObjectType):
)
name = graphene.String(description="Voucher name.")
code = graphene.String(
- required=False, description="Code to use the voucher." + DEPRECATED_IN_3X_FIELD
+ required=False,
+ description="Code to use the voucher. "
+ + DEPRECATED_IN_3X_FIELD
+ + " Use `addCodes` instead.",
)
add_codes = NonNullList(
graphene.String,
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 7fd68dacf2..05a1d1b17f 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -27924,7 +27924,9 @@ input VoucherInput @doc(category: "Discounts") {
"""Voucher name."""
name: String
- """Code to use the voucher.This field will be removed in Saleor 4.0."""
+ """
+ Code to use the voucher. This field will be removed in Saleor 4.0. Use `addCodes` instead.
+ """
code: String
"""
diff --git a/saleor/tests/e2e/checkout/test_checkout_use_voucher_for_cheapest_product.py b/saleor/tests/e2e/checkout/test_checkout_use_voucher_for_cheapest_product.py
index c299c3cf79..40416ea1a3 100644
--- a/saleor/tests/e2e/checkout/test_checkout_use_voucher_for_cheapest_product.py
+++ b/saleor/tests/e2e/checkout/test_checkout_use_voucher_for_cheapest_product.py
@@ -48,8 +48,13 @@ def prepare_voucher_for_cheapest_product(
@pytest.mark.e2e
@pytest.mark.parametrize(
- "first_variant_price, second_variant_price, voucher_discount_type, "
- "voucher_discount_value, expected_voucher_discount",
+ (
+ "first_variant_price",
+ "second_variant_price",
+ "voucher_discount_type",
+ "voucher_discount_value",
+ "expected_voucher_discount",
+ ),
[
("19.99", "109.99", "PERCENTAGE", 15, 3),
("13.33", "16.66", "FIXED", 4.44, 4.44),