Add LineItem for each variation
This commit is contained in:
parent
b009b1bc85
commit
13d016c888
@ -16,7 +16,8 @@ from core import (
|
||||
OrderStatus,
|
||||
ShippingMethodType,
|
||||
ShippingService,
|
||||
ShippingContainer
|
||||
ShippingContainer,
|
||||
CoffeeGrind
|
||||
)
|
||||
|
||||
from .payments import CreateOrder
|
||||
@ -172,14 +173,18 @@ class Cart:
|
||||
return response
|
||||
|
||||
def build_bulk_list(self, order):
|
||||
bulk_list = [OrderLine(
|
||||
order=order,
|
||||
product=item['product'],
|
||||
customer_note=f"{item['variations']}",
|
||||
unit_price=item['price'],
|
||||
quantity=item['quantity'],
|
||||
tax_rate=2,
|
||||
) for item in self]
|
||||
bulk_list = []
|
||||
|
||||
for item in self:
|
||||
for key, value in item['variations'].items():
|
||||
bulk_list.append(OrderLine(
|
||||
order=order,
|
||||
product=item['product'],
|
||||
customer_note=next((v[1] for i, v in enumerate(CoffeeGrind.GRIND_CHOICES) if v[0] == key), None),
|
||||
unit_price=item['price'],
|
||||
quantity=value['quantity'],
|
||||
tax_rate=2,
|
||||
))
|
||||
|
||||
return bulk_list
|
||||
|
||||
|
||||
@ -234,6 +234,8 @@ class OrderCreateView(CreateView):
|
||||
|
||||
return JsonResponse(data)
|
||||
|
||||
@csrf_exempt
|
||||
@require_POST
|
||||
def paypal_order_transaction_capture(request, transaction_id):
|
||||
if request.method =="POST":
|
||||
data = CaptureOrder().capture_order(transaction_id)
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport">
|
||||
<meta content="chrome=1" http-equiv="X-UA-Compatible">
|
||||
<title>{% block head_title %}{% endblock %} Port Townsend Coffee</title>
|
||||
<title>{% block head_title %}{% endblock %} Port Townsend Roasting Co.</title>
|
||||
<meta name="author" content="Nathan Chapman">
|
||||
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user