You need to use a custom template tag. Template filters take only one argument, while a custom template tag can take as many parameters as you need, perform multiplication, and return the value to the context.
You can check the documentation for the Django template tag , but a quick example:
@register.simple_tag() def multiply(qty, unit_price, *args, **kwargs):
Which you can name so:
{% load your_custom_template_tags %} {% for cart_item in cart.cartitem_set.all %} {% multiply cart_item.quantity cart_item.unit_price %} {% endfor %}
Are you sure you do not want this result to be a property of the cart item? It may seem that you need this information as part of your shopping cart when placing an order.
Brandon
source share