Update order status programmatically in magento

We can update order status of product in magento by using this below code. setState() function will do this for us, all we need is just pass the required arguments like state to be updated, status of the state, comment for the status change.


$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
$state = 'new';
$status = 'label_generated_by_user';
$comment = 'You have generated you shipping label';
$isCustomerNotified = true;
$order->setState($state, $status, $comment, $isCustomerNotified);
$order->save();
$order->sendOrderUpdateEmail(true, $comment);//Sending email notification to customer.


After updating order we can send notification to customer by using sendOrderUpdateEmail().

Comments

Popular posts from this blog

Send email from xampp localhost

Modify item price in cart after placing order using sales_quote_add_item

Convert long url to short url using tinyurl api