You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

methods.py 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from decimal import Decimal as D
  2. from django.template.loader import render_to_string
  3. from oscar.apps.shipping import base
  4. class Standard(base.ShippingMethod):
  5. code = 'standard'
  6. name = 'Standard shipping'
  7. description = render_to_string('shipping/standard.html')
  8. def basket_charge_incl_tax(self):
  9. # Free for orders over some threshold
  10. if self.basket.total_incl_tax > D('12.00'):
  11. return D('0.00')
  12. # Simple method - charge 0.99 per item
  13. total = D('0.00')
  14. charge_per_item = D('0.99')
  15. for line in self.basket.all_lines():
  16. total += line.quantity * charge_per_item
  17. return total
  18. def basket_charge_excl_tax(self):
  19. # Assume no tax
  20. return self.basket_charge_incl_tax()
  21. class Express(base.ShippingMethod):
  22. code = 'express'
  23. name = 'Express shipping'
  24. description = render_to_string('shipping/express.html')
  25. def basket_charge_incl_tax(self):
  26. # Simple method - charge 0.99 per item
  27. total = D('0.00')
  28. charge_per_item = D('1.50')
  29. for line in self.basket.all_lines():
  30. total += line.quantity * charge_per_item
  31. return total
  32. def basket_charge_excl_tax(self):
  33. # Assume no tax
  34. return self.basket_charge_incl_tax()