Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

calculators.py 1.2KB

1234567891011121314151617181920212223242526272829303132
  1. class OrderTotalCalculator(object):
  2. """
  3. Calculator class for calculating the order total.
  4. """
  5. def __init__(self, request=None):
  6. # We store a reference to the request as the total may
  7. # depend on the user or the other checkout data in the session.
  8. # Further, it is very likely that it will as shipping method
  9. # always changes the order total.
  10. self.request = request
  11. def order_total_incl_tax(self, basket, shipping_method=None, **kwargs):
  12. """
  13. Return order total including tax
  14. """
  15. # Default to returning the total including tax - use
  16. # the request.user object if you want to not charge tax
  17. # to particular customers.
  18. total = basket.total_incl_tax
  19. if shipping_method:
  20. total += shipping_method.basket_charge_incl_tax()
  21. return total
  22. def order_total_excl_tax(self, basket, shipping_method=None, **kwargs):
  23. """
  24. Return order total excluding tax
  25. """
  26. total = basket.total_excl_tax
  27. if shipping_method:
  28. total += shipping_method.basket_charge_excl_tax()
  29. return total