Skip to content

Commit

Permalink
Merge pull request #27 from ErhanCitil/feature/shipping-cost
Browse files Browse the repository at this point in the history
✨ [#16] Added shipping price
  • Loading branch information
ErhanCitil committed Nov 6, 2023
2 parents 1db5bb3 + ee92b15 commit 7409727
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/bobvance/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,17 @@ def get(self, request, *args, **kwargs):
[product.price * cart[str(product.id)] for product in cart_items]
)

if total_price <= 500:
shipping_price = 25
total_price += shipping_price

context = {
"cart_items": [
{"product": product, "quantity": cart[str(product.id)]}
for product in cart_items
],
"total_price": total_price,
"shipping_price": shipping_price,
}

return render(request, "base/cart.html", context)
Expand Down
4 changes: 4 additions & 0 deletions src/bobvance/templates/base/cart.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ <h2 class="text-lg font-bold text-gray-900">{{ item.product.name }}</h2>
</div>
<div class="flex justify-between">
<p class="text-gray-700">Verzenden</p>
{% if shipping_price %}
<p class="text-gray-700">€{{ shipping_price }}</p>
{% else %}
<p class="text-gray-700">Gratis</p>
{% endif %}
</div>
<hr class="my-4" />
<div class="flex justify-between">
Expand Down

0 comments on commit 7409727

Please sign in to comment.