magento修改订单状态、添加订单备注代码示例
Order API状态:
Resource Name:sales_order
Aliases:
.order
Methods:
sales_order.list-Retrieve list of orders by fiters
sales_order.info-Retrieve order information
sales_order.addComment-Add comment to order
sales_order.hold-hold order
sales_order.unhold-Unhold order
sales_order.cancel-Cancel order
magento自带函数:
public function addComment($orderIncrementId, $status, $comment = null, $notify = false)
{
$order = $this->_initOrder($orderIncrementId);
$order->addStatusToHistory($status, $comment, $notify);
try {
if ($notify && $comment) {
$oldStore = Mage::getDesign()->getStore();
$oldArea = Mage::getDesign()->getArea();
Mage::getDesign()->setStore($order->getStoreId());
Mage::getDesign()->setArea('frontend');
}
$order->save();
$order->sendOrderUpdateEmail($notify, $comment);
if ($notify && $comment) {
Mage::getDesign()->setStore($oldStore);
Mage::getDesign()->setArea($oldArea);
}
} catch (Mage_Core_Exception $e) {
$this->_fault('status_not_changed', $e->getMessage());
}
return true;
}
Magento addStatusToHistory这个函数可以同时修改订单状态和添加订单备注
Order API状态:
Resource Name:sales_order
Aliases:
.order
Methods:
sales_order.list-Retrieve list of orders by fiters
sales_order.info-Retrieve order information
sales_order.addComment-Add comment to order
sales_order.hold-hold order
sales_order.unhold-Unhold order
sales_order.cancel-Cancel order
magento自带函数:
public function addComment($orderIncrementId, $status, $comment = null, $notify = false)
{
$order = $this->_initOrder($orderIncrementId);
$order->addStatusToHistory($status, $comment, $notify);
try {
if ($notify && $comment) {
$oldStore = Mage::getDesign()->getStore();
$oldArea = Mage::getDesign()->getArea();
Mage::getDesign()->setStore($order->getStoreId());
Mage::getDesign()->setArea('frontend');
}
$order->save();
$order->sendOrderUpdateEmail($notify, $comment);
if ($notify && $comment) {
Mage::getDesign()->setStore($oldStore);
Mage::getDesign()->setArea($oldArea);
}
} catch (Mage_Core_Exception $e) {
$this->_fault('status_not_changed', $e->getMessage());
}
return true;
}
Magento addStatusToHistory这个函数可以同时修改订单状态和添加订单备注