marius2k12
marius2k12

Reputation: 1101

Finding out when an order status has been set to completed

I'm selling virtual products in my store where my customers buy a subscription for sth. This subscription is valid for 31 days beginning with the day when the order has been completed.

How do I find out the day when the order status had been set to completed?

My Idea was to look for the "updated_at" field of an order but I'm unsure if this is the right way to determine when the order was completed.

$sales_model = Mage::getModel("sales/order");
$all_orders  = $sales_model -> getCollection()
                ->addFieldToFilter('status', 'complete')
                ->addAttributeToFilter('updated_at', array(
                    'from' => $one_month_ago,
                    'to' => date('Y-m-d 24:00:00'),
                    'date' => true,
                    )
                );

Upvotes: 2

Views: 1226

Answers (1)

MagePal Extensions
MagePal Extensions

Reputation: 17656

The way I would approach this, is by create a custom module the keep track of the order status using observer

See Magento order status change events

Then log (in a db) the order # and date when the order was complete and expire. This way you could easily run report on when subscription will expire

Customize Magento using Event/Observe

Upvotes: 2

Related Questions