我试图以编程方式减少某些订单商品的数量,但更改不适用。这是我的尝试:
require_once('../app/Mage.php');
umask(0);
Mage::app();
$order = Mage::getModel('sales/order')->loadByIncrementId($_POST['order_id']);
foreach($order->getAllItems() as $item) {
$item->setQtyOrdered($item->getQtyOrdered() - 1)->save();
}
$order->setStatus("complete");
$history = $order->addStatusHistoryComment('Order was set to Complete by our automation tool.', false);
$history->setIsCustomerNotified(false);
$order->save();
答案 0 :(得分:0)
你试试这个
<?php
$order_id = 2314; //use your own order id
$order = Mage::getModel("sales/order")->load($order_id);
//load order by order id
$ordered_items = $order->getAllItems();
foreach($ordered_items as $item){ //item detail
$item->setQtyOrdered($item->getQtyOrdered() - 1)->save();
}
$order->setStatus("complete");
$history = $order->addStatusHistoryComment('Order was set to Complete by our automation tool.', false);
$history->setIsCustomerNotified(false);
$order->save();
?>