I have both android and web application running. Now i'm trying to assign coupon that can be redeemable only in mobile application.
To achieve this I've done below steps
Step 1 : To differentiate the order, I've created a custom column named order_via
in sales_flat_quote
table.
Step 2 : Using event observer i'm modifying order_via. i.e, when a product is added to cart via mobile it's order_via
value is Mobile App
and Web
when it is placed via web application.
Step 3 : Extended Mage_SalesRule_Model_Rule_Condition_Address to add custom Cart Attribute i.e, Order Via to existing rules (screenshot) using below code
class Namespace_Module_Model_Rule_Condition_Address extends Mage_SalesRule_Model_Rule_Condition_Address {
public function loadAttributeOptions() {
$attributes = array(
'base_subtotal' => Mage::helper('salesrule')->__('Subtotal'),
'total_qty' => Mage::helper('salesrule')->__('Total Items Quantity'),
'weight' => Mage::helper('salesrule')->__('Total Weight'),
'payment_method' => Mage::helper('salesrule')->__('Payment Method'),
'shipping_method' => Mage::helper('salesrule')->__('Shipping Method'),
'postcode' => Mage::helper('salesrule')->__('Shipping Postcode'),
'region' => Mage::helper('salesrule')->__('Shipping Region'),
'region_id' => Mage::helper('salesrule')->__('Shipping State/Province'),
'country_id' => Mage::helper('salesrule')->__('Shipping Country'),
'order_via' => Mage::helper('salesrule')->__('Order Via')
);
$this->setAttributeOption($attributes);
return $this;
}
}
I created a coupon with my new condition i.e Order Via Web. I've applied it in cart page but it's not working.
I think i need to add this custom column_id i.e, order_via to existing object. Don't know how. Any solution to make this work.