Add a affiliate points project in.
It took a turn.
First, add in the configuration file
code is as follows |
copy code |
<global * * * * * * * <sales> <quote> <totals> <**> <class>**/*** </class> <after>subtotal,freeshipping,tax_subtotal,shipping</after> <before> Grand_total</before> </**> </totals> <nominal_totals> <nominal_**> <class>**/**</class> <sort_order>550</sort_order> </nominal_**> </nominal_totals> </quote> </sales> * * * </global> |
The class under totals is modeled under model classes that must inherit from Mage_sales_model_quote_address_total_abstract, and Nominal_ The class under totals must inherit the class under totals.
The class under totals to implement 2 methods
The code is as follows |
Copy Code |
Public function Collect (mage_sales_model_quote_address $address) { Parent::collect ($address); $items = $this->_getaddressitems ($address); if (!count ($items)) { return $this; } $address->setaffiliatepointsamount (10); $address->setgrandtotal ($address->getgrandtotal () –10); $address->setbasegrandtotal ($address->getbasegrandtotal () -10); Return $this; } Public function fetch (mage_sales_model_quote_address $address) { $ Amount = $address->getaffiliatepointsamount (); if ($amount!= 0) { $title = Mage::helper (' affiliate ')->__ (' affiliate Points '); $address->addtotal ( Array ( ' code ' => $this->getcode (), ' title ' => $title, ' value ' =>-$amount )); } Return $this; } |
which
The code is as follows |
Copy Code |
$items = $this->_getaddressitems ($address); if (!count ($items)) { return $this; } |
This must be judged, or it may result in a repetitive calculation of prices.