feat: order creation on cart detail view

This commit is contained in:
2025-01-03 12:18:08 +01:00
parent 10b411ba33
commit 340c0d0508
9 changed files with 473 additions and 47 deletions
+26 -12
View File
@@ -73,22 +73,36 @@ def delete_product_batch(batch: ProductBatch):
def create_order_from_cart(
cart: Cart,
billing_address: CustomerAddress,
shipping_address: CustomerAddress,
shipping_method: ShippingMethod,
billing_address_full_name="",
billing_address_address="",
billing_address_town="",
billing_address_state="",
billing_address_country="",
billing_address_zip="",
shipping_address_full_name="",
shipping_address_address="",
shipping_address_town="",
shipping_address_state="",
shipping_address_country="",
shipping_address_zip="",
shipping_address_phone="",
email="",
):
order = Order.objects.create(
billing_address=billing_address.address,
billing_city=billing_address.address_town,
billing_state=billing_address.address_state,
billing_country=billing_address.address_country,
billing_zip=billing_address.address_zip,
shipping_address=shipping_address.address,
shipping_city=shipping_address.address_town,
shipping_state=shipping_address.address_state,
shipping_country=shipping_address.address_country,
shipping_zip=shipping_address.address_zip,
billing_address=f'{billing_address_full_name} {billing_address_address}',
billing_city=billing_address_town,
billing_state=billing_address_state,
billing_country=billing_address_country,
billing_zip=billing_address_zip,
contact_phone=shipping_address_phone,
shipping_address=f'{shipping_address_address} {shipping_address_full_name}',
shipping_city=shipping_address_town,
shipping_state=shipping_address_state,
shipping_country=shipping_address_country,
shipping_zip=shipping_address_zip,
user=cart.user,
email=email,
)
for item in cart.items.all():