四月
5
2010

人工创建magento invoice和Shipping

// load order
$order = Mage::getModel(‘sales/order’)->load($orderId);

// set store and locale according to order store
Mage::app()->setCurrentStore($order->getStoreId());
Mage::app()->getLocale()->emulate($order->getStoreId());

// create invoice and send email
if ($order->canInvoice()) {
$invoice = $order->prepareInvoice();
$invoice->register();
$invoice->setEmailSent(true);
$invoice->save();
$invoice->sendEmail();
}

// create shipment and send email
if ($order->canShip()) {
$shipment = $order->prepareShipment();
$shipment->register();
$shipment->setEmailSent(true);
$shipment->save();
$shipment->sendEmail();
}

// save order
$order->save();

// reset locale
Mage::app()->getLocale()->revert();

相关文章

我要评论

标签