Fix Decimal+float TypeError in cart total calculation
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 57s
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:
@@ -1,6 +1,12 @@
|
|||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
|
|
||||||
def total(cart):
|
def total(cart):
|
||||||
return sum(
|
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
|
for item in cart
|
||||||
if (item.product.special_price or item.product.regular_price) is not None
|
if (item.product.special_price or item.product.regular_price) is not None
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user