The conditions would be:

1) customers only

2) One time use only

3) must have previous order

#1 and #2 are straight forward, but what is a good approach to only giving this to customers that have placed an order?

  • Which Magento version you are using? In EE you can use the concept of Customer Segmentation + Shopping Cart price rules.
    – MagePsycho
    Commented May 26, 2014 at 9:02

1 Answer 1


First you need to get the count of the orders that the customer has made:

$customer_id = some id;  
$ordersCollection = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id',$customer_id);  
$orderCount = $ordersCollection->count();  
if($orderCount == 1){       
    $order = $ordersCollection->getFirstItem();
    //Check order status (closed, complete etc)  
    if($order->getStatusLabel() == "complete"){   
        // apply discount here 
  • Where would I put this code?
    – kevando
    Commented Apr 28, 2014 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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