How to Add Setup Pricing to a Product

Last modified by JMarkMurphy on Tue, December 23, 2008 16:02
Source|Old Revisions  

This is an old revision of the document!


The goal of this extension is to create a pricing structure that allows tier pricing for large quantity ordering, but also provides for a setup fee that is not dependent on the quantity ordered to be included in the price of the product. The final pricing formula would look something like this:

final price = (unit price * quantity) + setup fee

Custom options with prices do not work in this model because they are included in the unit price of the product. I will use a price type attribute to hold the setup fee for the product.

Create a New Module

The goal here is to create a new module that can be used to provide the desired pricing function without changing the core Magento code. Throughout this example I will be using the local code pool with a namespace of Company. The module name will be MyModule, and the base Magento directory will be /Magento.

To create the new module we will add the following directories to our Magento install:


In addition we will need to notify Magento of this new module by creating the following file:


  1. <?xml version="1.0" encoding="UTF-8"?>
  3. <config>
  4.     <modules>
  5.         <Company_MyModule>
  6.             <active>true</active>
  7.             <codePool>local</codePool>
  8.         </Company_MyModule>
  9.     </modules>
  10. </config>

Edit config.xml

config.xml describes the module structure to Magento and, in this example, handles the rewrites necessary to tell Magento where our extended classes are, and which classes they replace. Create this file:


  1. <?xml version="1.0" encoding="UTF-8"?>
  3. <config>
  5.     <modules>
  6.         <Company_MyModule>
  7.             <version>0.1.0</version>
  8.         </Company_MyModule>
  9.     </modules>
  11.     <global>
  12.         <blocks>
  13.             <checkout>
  14.                 <rewrite>
  15.                     <cart_item_renderer>Company_MyModule_Block_Cart_Item_Renderer</cart_item_renderer>
  16.                 </rewrite>
  17.             </checkout>
  18.         </blocks>   
  20.         <models>
  21.             <mymodule>
  22.                 <class>Company_MyModule_Model</class>
  23.             </mymodule>
  24.             <sales>
  25.                 <rewrite>
  26.                     <quote_item>Company_MyModule_Model_Quote_Item</quote_item>
  27.                 </rewrite>
  28.             </sales>
  29.         </models>
  30.     </global>
  32. </config>

Extend the Renderer

Extend the Sales/Model/Quote/Item.php

Modify Templates