How to add custom product pricing module
In this tutorial you will learn how to your own custom product pricing module.
Create an application
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.
Implement the price calculator class
Within __init__.py file of your application (or anywhere you choose) create
a class that inherits from lfs.plugins.PricingCalculator and implement all
inherited methods.
from lfs.plugins import PriceCalculator
class CustomPriceCalculator(PriceCalculator):
def get_price(self, with_properties=True):
return self.get_price_net()
... Other Methods...
Plug in the custom price calculator
Add your application to the PYTHONPATH.
Add the application to settings.INSTALLED_APPS.
If your are using models (which is completely up to you), sync your database.
Edit the dictionary lfs.core.settings.LFS_PRICE_CALCULATORS to make your custom pricing calculator available to products in the manage interface
LFS_PRICE_CALCULATORS = [
["lfs.gross_price.calculator.GrossPriceCalculator", _(u"Price includes tax")],
["lfs.net_price.calculator.NetPriceCalculator", _(u"Price excludes tax")],
["mycustom_price.CustomPriceCalculator", _(u"My Pricing Calculator")],
]
Set the shop default price calculator
Go to the LFS Management Interface.
Select
Shop / Preferences.Select
Default Valuesand go thePrice Calculatorsection.Select your new pricing calculator from the drop down menu of choices.
Save the default values.
Note
All products with an unset price calculator will default to using the shop price calculator.
Set the product pricing calculator
Browse to http://yourshopdomain/manage and login.
Select
Catalog / Product.Select the product whose price calculator you wish to change.
Select the
Data Taband scroll to thePricessection.Select your new pricing calculator from the drop down menu.
Click on
Save Data.Now browse to the customer view of the product and you should see the price as calculated by your custom pricing calculator.