validation for quantity
This commit is contained in:
@@ -31,6 +31,7 @@ class CartItemViews(APIView):
|
||||
product_variant = get_object_or_404(ProductVariant, pk=pk)
|
||||
response = 'محصول با موفقیت به سبد خرید اضافه شد'
|
||||
quantity = request.data.get('quantity', 1)
|
||||
quantity = max(quantity, 0)
|
||||
if product_variant.in_stock < quantity:
|
||||
quantity = product_variant.in_stock
|
||||
response = 'تعداد درخواستی بیشتر از موجودی محصول میباشد'
|
||||
|
||||
Reference in New Issue
Block a user