-
- sanya_g

-
Total Posts: 3
Joined: 2011-09-03
|
So, as I thought I dug into Magento promotion features and hopefully find out a solution.
First I override Mage_SalesRule_Model_Rule_Condition_Combine
and made some changes to add new condition:
$conditions = array_merge_recursive($conditions, array( array(`value`=>`salesrule/rule_condition_orders`, `label` => `Order count`), // <-- this is my line array(`value`=>`salesrule/rule_condition_product_found`, `label`=>Mage::helper(`salesrule`)->__(`Product attribute combination`)), array(`value`=>`salesrule/rule_condition_product_subselect`, `label`=>Mage::helper(`salesrule`)->__(`Products subselection`)), array(`value`=>`salesrule/rule_condition_combine`, `label`=>Mage::helper(`salesrule`)->__(`Conditions combination`)), array(`label`=>Mage::helper(`salesrule`)->__(`Cart Attribute`), `value`=>$attributes), ));
Than I`ve created Mage_SalesRule_Model_Rule_Condition_Orders class
class Mage_SalesRule_Model_Rule_Condition_Orders extends Mage_Rule_Model_Condition_Abstract { public function getAttributeElementHtml() { return `Number of orders with the same Email`; } public function validate(Varien_Object $object) { $email = $object->getEmail(); $orderCollection = Mage::getResourceModel(`sales/order_collection`); $orderCollection->addFieldToFilter(`state`, array(`in` => `complete`)); $orderCollection->addFieldToFilter(`customer_email`, array(`in` => $email)); $orderCollection->load(); $count = $orderCollection->count(); return $this->validateAttribute($count); } }
After that I`ve added discount rules from Promotion -> Shopping Cart Price Rules.
Maybe code is not ideal, but it works
I hope this post can help someone else.
P.S. MrManners, Thanks for your trials to help.
|