def total(cart):
    return sum(
        (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
    )
