Fix Decimal+float TypeError in cart total calculation
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 57s

Product prices are float from DB but calendar/ticket totals are Decimal,
causing TypeError when summed in cart_context. Wrap prices in Decimal().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-21 21:11:54 +00:00
parent e41d22746e
commit e86c4a0cc8

View File

@@ -1,6 +1,12 @@
from decimal import Decimal
def total(cart):
return sum(
(item.product.special_price or item.product.regular_price) * item.quantity
(
Decimal(str(item.product.special_price or item.product.regular_price))
* item.quantity
)
for item in cart
if (item.product.special_price or item.product.regular_price) is not None
)