add: add new field for product

This commit is contained in:
behruz-dev
2025-09-05 17:02:35 +05:00
parent 2f7a15d474
commit 90ba73e054
4 changed files with 29 additions and 4 deletions

View File

@@ -48,12 +48,17 @@ class OrderCreateSerializer(serializers.Serializer):
total_price = 0
total_price += validated_data.get('delivery_price')
for item in order_items:
product = item.get("product")
items.append(OrderItem(
product=item.get('product'),
product=product,
price=item.get('price'),
quantity=item.get('quantity'),
order=order,
))
if product.quantity_left > 0:
product.quantity_left -= item.get('quantity')
product.save()
total_price += item.get('price')
send_orders_to_tg_bot.delay(
chat_id=item.get('product').tg_id,