Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use maximum orderable quantity defined in settings
Artur Smęt68f740ea3e94
diff --git a/saleor/cart/forms.py b/saleor/cart/forms.pyindex 8611ef40e3..bfb22c8631 100644--- a/saleor/cart/forms.py+++ b/saleor/cart/forms.py@@ -2,6 +2,7 @@ from __future__ import unicode_literalsfrom django import formsfrom django.core.exceptions import ObjectDoesNotExist, NON_FIELD_ERRORS+from django.conf import settingsfrom django.utils.translation import pgettext_lazy, ugettext_lazyfrom satchless.item import InsufficientStock@@ -9,8 +10,9 @@ from satchless.item import InsufficientStockclass QuantityField(forms.IntegerField):def __init__(self, **kwargs):- super(QuantityField, self).__init__(min_value=0, max_value=999,- initial=1, **kwargs)+ super(QuantityField, self).__init__(+ min_value=0, max_value=settings.MAX_CART_LINE_QUANTITY,+ initial=1, **kwargs)class AddToCartForm(forms.Form):@@ -87,7 +89,7 @@ class ReplaceCartLineForm(AddToCartForm):super(ReplaceCartLineForm, self).__init__(*args, **kwargs)self.cart_line = self.cart.get_line(self.variant)self.fields['quantity'].widget.attrs = {- 'min': 1, 'max': self.variant.get_stock_quantity()}+ 'min': 1, 'max': settings.MAX_CART_LINE_QUANTITY}def clean_quantity(self):quantity = self.cleaned_data['quantity']diff --git a/saleor/settings.py b/saleor/settings.pyindex 9f7c4a2334..ae6ebfb52d 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -258,6 +258,7 @@ MESSAGE_TAGS = {messages.ERROR: 'danger'}LOW_STOCK_THRESHOLD = 10+MAX_CART_LINE_QUANTITY = os.environ.get('MAX_CART_LINE_QUANTITY', 50)PAGINATE_BY = 16