I would like to create an if with php where I assign an action if the current customer registered on my site in magento does not place an order after 6 months from his last order.
if(customer not place an order in six months){
//action
} else { //ok }
How can I do?
this is my try:
Sure: $_customer = Mage::getSingleton('customer/session')->getCustomer();
$orders = Mage::getResourceModel('sales/order_collection')
->addFieldToSelect('*')
->addFieldToFilter('customer_id', $_customer->getId())
->addAttributeToSort('created_at', 'DESC')
->setPageSize(1);
$date_order_creation=$orders->getFirstItem()->getCreatedAt();
$previous_date = date('Y-m-d');
$date_a = new DateTime($date_order_creation);
$date_b = new DateTime($previous_date);
$interval = date_diff($date_a,$date_b);
if($interval->format('%d') > 1){
echo 'more 1 day';
}else{
echo 'not yet 1 day';
}