Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Change order of parameters in add_voucher_to_checkout function
fowczarek87cb34194fc9
diff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.pyindex ca4a29f355..bfbf515639 100644--- a/saleor/checkout/utils.py+++ b/saleor/checkout/utils.py@@ -807,14 +807,14 @@ def add_voucher_code_to_checkout(checkout: Checkout, voucher_code: str):except Voucher.DoesNotExist:raise ValidationError({"promo_code": "Voucher with given code is invalid."})try:- add_voucher_to_checkout(voucher, checkout)+ add_voucher_to_checkout(checkout, voucher)except NotApplicable:raise ValidationError({"promo_code": "Voucher is not applicable to that checkout."})-def add_voucher_to_checkout(voucher: Voucher, checkout: Checkout):+def add_voucher_to_checkout(checkout: Checkout, voucher: Voucher):"""Add voucher data to checkout.Raise NotApplicable if voucher of given type cannot be applied."""diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.pyindex 06c471475d..94da5b2b78 100644--- a/saleor/graphql/checkout/mutations.py+++ b/saleor/graphql/checkout/mutations.py@@ -553,7 +553,7 @@ class CheckoutUpdateVoucher(BaseMutation):)try:- add_voucher_to_checkout(voucher, checkout)+ add_voucher_to_checkout(checkout, voucher)except voucher_model.NotApplicable:raise ValidationError({"voucher_code": "Voucher is not applicable to that checkout."}diff --git a/tests/api/test_checkout_promo_codes.py b/tests/api/test_checkout_promo_codes.pyindex 1cc2a9cddd..f6a3436e8d 100644--- a/tests/api/test_checkout_promo_codes.py+++ b/tests/api/test_checkout_promo_codes.py@@ -91,7 +91,7 @@ def test_checkout_lines_delete_with_not_applicable_voucher(voucher.min_amount_spent = checkout_with_item.get_subtotal().grossvoucher.save(update_fields=["min_amount_spent"])- add_voucher_to_checkout(voucher, checkout_with_item)+ add_voucher_to_checkout(checkout_with_item, voucher)assert checkout_with_item.voucher_code == voucher.codeline = checkout_with_item.lines.first()@@ -128,7 +128,7 @@ def test_checkout_shipping_address_update_with_not_applicable_voucher(voucher = voucher_shipping_typeassert voucher.countries[0].code == address_other_country.country- add_voucher_to_checkout(voucher, checkout_with_item)+ add_voucher_to_checkout(checkout_with_item, voucher)assert checkout_with_item.voucher_code == voucher.codecheckout_id = graphene.Node.to_global_id("Checkout", checkout_with_item.pk)diff --git a/tests/test_checkout.py b/tests/test_checkout.pyindex 1898300e0b..1df88e24d8 100644--- a/tests/test_checkout.py+++ b/tests/test_checkout.py@@ -1290,7 +1290,7 @@ def test_get_prices_of_products_in_discounted_categories(checkout_with_item):def test_add_voucher_to_checkout(checkout_with_item, voucher):assert checkout_with_item.voucher_code is None- add_voucher_to_checkout(voucher, checkout_with_item)+ add_voucher_to_checkout(checkout_with_item, voucher)assert checkout_with_item.voucher_code == voucher.code@@ -1299,6 +1299,6 @@ def test_add_voucher_to_checkout_fail(checkout_with_item, voucher_with_high_min_amount_spent):with pytest.raises(NotApplicable):- add_voucher_to_checkout(voucher_with_high_min_amount_spent, checkout_with_item)+ add_voucher_to_checkout(checkout_with_item, voucher_with_high_min_amount_spent)assert checkout_with_item.voucher_code is None