最新消息:觉得本站不错的话 记得收藏哦 博客内某些功能仅供测试 讨论群:135931704 快养不起小站了 各位有闲钱就打赏下把 My Email weicots#gmail.com Please replace # with @

magento 更改订单状态代码

Magento 资料整理 ajiang-tuzi 6231浏览
/*
*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 更改订单状态代码

蜀ICP备15020253号-1