In this tutorial you will learn how to your own custom product pricing module.
First you need to create a default Django application (or use an existing one).
If you do not know how to do this, please refer to the excellent Django tutorial.
Within __init__.py file of your application (or anywhere you choose) create a class that inherits from lfs.price.PricingCalculator and implement all inherited methods.
from lfs.price import PriceCalculator
class CustomPriceCalculator(PriceCalculator):
def get_price(self, with_properties=True):
return self.get_price_net()
... Other Methods...
Add your custom price calculator to lfs.core.settings.LFS_PRICE_CALCULATOR_DICTIONARY
Edit the dictionary lfs.core.settings.LFS_PRICE_CALCULATOR_DICTIONARY to make your custom pricing calculator available to products in the manage interface
LFS_PRICE_CALCULATOR_DICTIONARY = {
'lfs.gross_price.GrossPriceCalculator': 'Price including tax',
'lfs.net_price.NetPriceCalculator': 'Price excluding tax',
'mycustom_price.CustomPriceCalculator': 'My Pricing Calculator',
}
All products with an unset price calculator will default to using the shop price calculator.