Magento get coupon codes used by customer


Magento get coupon codes used by customer : You Can Get Coupon code used by particular user by following query.


Syntax : Magento get coupon codes used by customer

$collection = Mage::getModel('sales/order')->getCollection();
			$collection->getSelect()->join(array('coupon'=> salesrule_coupon), 'coupon.code = main_table.coupon_code', array('coupon.type'))
                 ->join( array('coupon_usage'=> salesrule_coupon_usage), '(coupon_usage.coupon_id = coupon.coupon_id AND coupon_usage.customer_id = "'.$customerId.'") ', array('*'));
//pass customer Id to load coupon used by the customer  - $customerId 

$customerId – is customer id, load coupon codes used by this customer


Advertisements

Add Comment

📖 Read More