Skip to content

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

Change VoucherType from VALUE to ENTIRE_ORDER

fowczarek11e95f09dd63
diff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.py
index 42c8f3cc07..5df91cef2c 100644
--- a/saleor/checkout/utils.py
+++ b/saleor/checkout/utils.py
@@ -740,7 +740,7 @@ def get_voucher_discount_for_checkout(voucher, checkout, discounts=None, taxes=N
Raise NotApplicable if voucher of given type cannot be applied.
"""
- if voucher.type == VoucherType.VALUE:
+ if voucher.type == VoucherType.ENTIRE_ORDER:
return get_value_voucher_discount(
voucher, checkout.get_subtotal(discounts, taxes)
)
diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.py
index 1b2d4055af..aa23a477f1 100644
--- a/saleor/core/utils/random_data.py
+++ b/saleor/core/utils/random_data.py
@@ -792,7 +792,7 @@ def create_vouchers():
voucher, created = Voucher.objects.get_or_create(
code="DISCOUNT",
defaults={
- "type": VoucherType.VALUE,
+ "type": VoucherType.ENTIRE_ORDER,
"name": "Big order discount",
"discount_value_type": DiscountValueType.FIXED,
"discount_value": 25,
diff --git a/saleor/dashboard/discount/views.py b/saleor/dashboard/discount/views.py
index 097e181491..181c690722 100644
--- a/saleor/dashboard/discount/views.py
+++ b/saleor/dashboard/discount/views.py
@@ -22,8 +22,8 @@ def get_voucher_type_forms(voucher, data):
VoucherType.SHIPPING: forms.ShippingVoucherForm(
data or None, instance=voucher, prefix=VoucherType.SHIPPING
),
- VoucherType.VALUE: forms.ValueVoucherForm(
- data or None, instance=voucher, prefix=VoucherType.VALUE
+ VoucherType.ENTIRE_ORDER: forms.ValueVoucherForm(
+ data or None, instance=voucher, prefix=VoucherType.ENTIRE_ORDER
),
VoucherType.PRODUCT: forms.ProductVoucherForm(
data or None, instance=voucher, prefix=VoucherType.PRODUCT
diff --git a/saleor/dashboard/order/utils.py b/saleor/dashboard/order/utils.py
index 1d0331cf6f..af281e8f99 100644
--- a/saleor/dashboard/order/utils.py
+++ b/saleor/dashboard/order/utils.py
@@ -80,7 +80,7 @@ def get_voucher_discount_for_order(order):
"""
if not order.voucher:
return ZERO_MONEY
- if order.voucher.type == VoucherType.VALUE:
+ if order.voucher.type == VoucherType.ENTIRE_ORDER:
return get_value_voucher_discount(order.voucher, order.get_subtotal())
if order.voucher.type == VoucherType.SHIPPING:
return get_shipping_voucher_discount(
diff --git a/saleor/discount/__init__.py b/saleor/discount/__init__.py
index b852a5c833..15187a49fe 100644
--- a/saleor/discount/__init__.py
+++ b/saleor/discount/__init__.py
@@ -20,10 +20,10 @@ class VoucherType:
COLLECTION = "collection"
CATEGORY = "category"
SHIPPING = "shipping"
- VALUE = "value"
+ ENTIRE_ORDER = "entire_order"
CHOICES = [
- (VALUE, pgettext_lazy("Voucher: discount for", "All products")),
+ (ENTIRE_ORDER, pgettext_lazy("Voucher: discount for", "All products")),
(PRODUCT, pgettext_lazy("Voucher: discount for", "Specific products")),
(
COLLECTION,
diff --git a/saleor/discount/models.py b/saleor/discount/models.py
index ca56931c9b..a0f8c79923 100644
--- a/saleor/discount/models.py
+++ b/saleor/discount/models.py
@@ -44,7 +44,7 @@ class VoucherQueryset(models.QuerySet):
class Voucher(models.Model):
type = models.CharField(
- max_length=20, choices=VoucherType.CHOICES, default=VoucherType.VALUE
+ max_length=20, choices=VoucherType.CHOICES, default=VoucherType.ENTIRE_ORDER
)
name = models.CharField(max_length=255, null=True, blank=True)
code = models.CharField(max_length=12, unique=True, db_index=True)
diff --git a/saleor/graphql/discount/enums.py b/saleor/graphql/discount/enums.py
index 4e707cfe29..7cc6be0c4d 100644
--- a/saleor/graphql/discount/enums.py
+++ b/saleor/graphql/discount/enums.py
@@ -13,7 +13,7 @@ class VoucherTypeEnum(graphene.Enum):
COLLECTION = VoucherType.COLLECTION
CATEGORY = VoucherType.CATEGORY
SHIPPING = VoucherType.SHIPPING
- VALUE = VoucherType.VALUE
+ ENTIRE_ORDER = VoucherType.ENTIRE_ORDER
class DiscountStatusEnum(graphene.Enum):