magento 更改订单状态代码

7天成为Magento系统架构师,现在开始学习Magento全栈开发!

《Magento2.X企业级开发实战》

/*
*www.weicot.com
*0.1.3
*No 21
*/
$orderId = YOUR_ORDER_ID;
$order = Mage::getModel(‘sales/order’)->load($orderId);
$orderIncrementId = YOUR_ORDER_INCREMENT_ID;
$order = Mage::getModel(‘sales/order’)->loadByIncrementId($orderIncrementId);

Change order status to Complete

/**
* change order status to ‘Completed’
*/
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE,true)->save();

Change the order status to pending, processing, canceled, closed, holded, etc.

/**
* change order status to ‘Pending’
*/
$order->setState(Mage_Sales_Model_Order::STATE_NEW,true)->save();
/**
* change order status to ‘Pending Paypal’
*/
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,true)->save();
/**
* change order status to ‘Processing’
*/
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING,true)->save();
/**
* change order status to ‘Completed’
*/
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE,true)->save();
/**
* change order status to ‘Closed’
*/
$order->setState(Mage_Sales_Model_Order::STATE_CLOSED,true)->save();
/**
* change order status to ‘Canceled’
*/
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED,true)->save();
/**
* change order status to ‘Holded’
*/
$order->setState(Mage_Sales_Model_Order::STATE_HOLDED,true)->save();

Cancel an order

if($order->canCancel()){
$order->cancel()->save();
}

Hold an order

if($order->canHold()){
$order->hold()->save();
}

Unhold an order

if($order->canUnhold()){
$order->unhold()->save();
}

转载请注明:(●--●) Hello.My Weicot » magento 更改订单状态代码

文章来源于互联网:magento 更改订单状态代码

如无特殊说明或标注,任何个人或组织,复制、转载、采集本站内容请注明:
本文来源于:【Magento中文网】,并添加本文地址链接。
如未按上述操作复制或转载,本站有权追究法律责任。
若本站内容侵犯了原著者的合法权益,可联系我们进行处理。