def _order_totals(context):
 fields = [u'shipping_type', u'shipping_total', u'discount_total', u'tax_type', u'tax_total']
 template_vars = {}
 if (u'order' in context):
  for field in (fields + [u'item_total']):
   template_vars[field] = getattr(context[u'order'], field)
 else:
  template_vars[u'item_total'] = context[u'request'].cart.total_price()
  if (template_vars[u'item_total'] == 0):
   template_vars[u'tax_total'] = 0
   template_vars[u'discount_total'] = 0
   template_vars[u'shipping_total'] = 0
  else:
   for field in fields:
    template_vars[field] = context[u'request'].session.get(field, None)
 template_vars[u'order_total'] = template_vars.get(u'item_total', None)
 if (template_vars.get(u'shipping_total', None) is not None):
  template_vars[u'order_total'] += Decimal(str(template_vars[u'shipping_total']))
 if (template_vars.get(u'discount_total', None) is not None):
  template_vars[u'order_total'] -= Decimal(str(template_vars[u'discount_total']))
 if (template_vars.get(u'tax_total', None) is not None):
  template_vars[u'order_total'] += Decimal(str(template_vars[u'tax_total']))
 return template_vars

def _order_totals ( context ) : fields = [ u'shipping_type' , u'shipping_total' , u'discount_total' , u'tax_type' , u'tax_total' ] template_vars = { } if ( u'order' in context ) : for field in ( fields + [ u'item_total' ] ) : template_vars [ field ] = getattr ( context [ u'order' ] , field ) else : template_vars [ u'item_total' ] = context [ u'request' ] . cart . total_price ( ) if ( template_vars [ u'item_total' ] == 0 ) : template_vars [ u'tax_total' ] = 0 template_vars [ u'discount_total' ] = 0 template_vars [ u'shipping_total' ] = 0 else : for field in fields : template_vars [ field ] = context [ u'request' ] . session . get ( field , None ) template_vars [ u'order_total' ] = template_vars . get ( u'item_total' , None ) if ( template_vars . get ( u'shipping_total' , None ) is not None ) : template_vars [ u'order_total' ] += Decimal ( str ( template_vars [ u'shipping_total' ] ) ) if ( template_vars . get ( u'discount_total' , None ) is not None ) : template_vars [ u'order_total' ] -= Decimal ( str ( template_vars [ u'discount_total' ] ) ) if ( template_vars . get ( u'tax_total' , None ) is not None ) : template_vars [ u'order_total' ] += Decimal ( str ( template_vars [ u'tax_total' ] ) ) return template_vars
add shipping/tax/discount/order types and totals to the template context .