Is it possible to find sales by a particular coupon code?


Is it possible to read orders on which a particular coupon code is applied?

I wrote a script earlier to filter orders on which discounts were applied?

$from_date = date("Y-m-d", strtotime($_REQUEST['from_date']));
$to_date = date("Y-m-d", strtotime($_REQUEST['to_date']));

$orders = Mage::getModel('sales/order')->getCollection()
    ->addAttributeToFilter('created_at', array('from'=>$from_date, 'to'=>$to_date))
    ->addAttributeToFilter('status', array('eq' => Mage_Sales_Model_Order::STATE_COMPLETE));

$orders->addFieldToFilter('base_discount_amount', array('lt' => 0));



Yes you can definitely do this, see the following code:

$orders = Mage::getModel('sales/order')->getCollection()

Where 'your_coupon_code' represents the value of your coupon code.


You can check particular order have coupon code or not using below code

$order = Mage::getModel('sales/order')->loadByIncrementId('100000033');  
// 100000033 your order increment id
    echo $order->getCouponCode();

You can filter order by particular coupon code as Digital Pianism answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.