parent
92d4e0dd71
commit
683fdc08a6
|
@ -14,7 +14,7 @@
|
|||
</p>
|
||||
{% endif %}
|
||||
<h3>List of Items in your Order:</h3>
|
||||
{% if order_position_list %}
|
||||
{% if order_position_list_zip %}
|
||||
<table class="table price-table">
|
||||
<tr class="table_header">
|
||||
<th scope="col">POS.</th>
|
||||
|
@ -22,9 +22,10 @@
|
|||
<th scope="col">NAME</th>
|
||||
<th scope="col">STOCK</th>
|
||||
<th scope="col">AMOUNT</th>
|
||||
<th scope="col" class="price-label">PRICE p.pce.</th>
|
||||
<th scope="col" class="price-label">POSITION PRICE</th>
|
||||
</tr>
|
||||
{% for order_position in order_position_list %}
|
||||
{% for order_position, price, pos_price in order_position_list_zip %}
|
||||
<tr class="table_content">
|
||||
<td scope="col">{{ order_position.id }}</td>
|
||||
<td scope="col">{{ order_position.article.id }}</td>
|
||||
|
@ -36,12 +37,16 @@
|
|||
<td scope="col">{{ order_position.article.stock }}</td>
|
||||
<td scope="col">{{ order_position.amount }}</td>
|
||||
<td scope="col" class="price-value">
|
||||
{{ order_postion.price_in_chf }} {{ currency_name }}
|
||||
{{ price }}
|
||||
{{ currency_name }}
|
||||
</td>
|
||||
<td scope="col" class="price-value">
|
||||
{{ pos_price }} {{ currency_name }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr>
|
||||
<td scope="col" colspan="4"class="text-right">
|
||||
<td scope="col" colspan="5"class="text-right">
|
||||
<td scope="col" class="price-value">
|
||||
<dl><dt>Total:</dl></dt></td>
|
||||
<td scope="col" class="price-value">
|
||||
|
|
|
@ -422,8 +422,9 @@ def checkout(request):
|
|||
|
||||
def order(request, order_id):
|
||||
category_list = get_categories()
|
||||
price_list = []
|
||||
totalprice_list = []
|
||||
order_position_list = []
|
||||
order_position_list_zip = []
|
||||
cart = ShoppingCart.objects.get(user=request.user)
|
||||
if cart:
|
||||
# get all items in the cart of this customer:
|
||||
|
@ -437,26 +438,35 @@ def order(request, order_id):
|
|||
'delete'
|
||||
)
|
||||
else:
|
||||
message = """Something went wrong.
|
||||
We could not empty your cart. """
|
||||
message = """something whent wrong.
|
||||
We cold not empty your cart. """
|
||||
order = Order.objects.get(id=order_id)
|
||||
order_positions = OrderPosition.objects.filter(order=order_id)
|
||||
|
||||
if order.exchange_rate is not None:
|
||||
currency_name = order.exchange_rate.name
|
||||
else:
|
||||
currency_name = 'CHF'
|
||||
|
||||
if (order_positions.count()) > 0:
|
||||
order_position_list = list(order_positions)
|
||||
for idx, order_position in enumerate(order_position_list):
|
||||
for idx, order_position in enumerate(order_positions):
|
||||
# get currencyname to display:
|
||||
totalprice_list.append(order_position.price_in_chf)
|
||||
print(order_position.price_in_chf)
|
||||
if order.exchange_rate is not None:
|
||||
# get price of position in order and append to a list:
|
||||
rate = ExchangeRate.objects.get(id=order.exchange_rate.id)
|
||||
price = round(
|
||||
rate.exchange_rate_to_chf * order_position.price_in_chf,
|
||||
2)
|
||||
currency_name = order.exchange_rate.name
|
||||
else:
|
||||
currency_name = 'CHF'
|
||||
price = order_position.price_in_chf
|
||||
position_price = price * Decimal.from_float(order_position.amount)
|
||||
order_position_list[idx] = order_position
|
||||
price_list.append(price)
|
||||
totalprice_list.append(position_price)
|
||||
total = sum(totalprice_list)
|
||||
order_position_list_zip = zip(order_position_list,
|
||||
price_list,
|
||||
totalprice_list)
|
||||
return render(request, 'webshop/order.html', {
|
||||
'order': order,
|
||||
'order_position_list': order_positions,
|
||||
'order_position_list_zip': order_position_list_zip,
|
||||
'total': total,
|
||||
'currency_name': currency_name,
|
||||
'category_list': category_list,
|
||||
|
|
Loading…
Reference in New Issue