基本上,我试图在magento上制作财务部分,我已经研究了如何下订单作为财务提交的一部分,我看到的地方使用下面的代码(不完全):
$order = Mage::getModel('sales/order');
$store = Mage::app()->getStore();
$website_id = Mage::app()->getWebsite()->getStoreId();
$quote = Mage::getModel('sales/order')->setStoreId($store->getId());
$customer = Mage::getSingleton('customer/session')->getCustomer();
$quote->assignCustomer($customer);
$quote->setSendCconfirmation(1);
$product_ids = array();
$cart = Mage::getModel('checkout/cart')->getQuote();
foreach($cart->getAllVisibleItems() as $item) {
$quote->addProduct($item->getProduct() , $item->getQty());
}
$shipping = $quote->getShippingAddress();
$shipping->setCollectShippingRates(true)->collectShippingRates()->setShippingMethod('flatrate_flatrate')->setPaymentMethod(array(
'method' => 'checkmo'
));
try {
$service = Mage::getModel('sales/service_quote', $quote);
$service->submitAll();
$increment_id = $service->getOrder()->getRealOrderId();
}
catch(Exception $e) {
die($e->getMessage());
}
catch(Mage_Core_Exception $d) {
die($d->getMessage());
}
由于某些原因,我不断收到此错误:
答案 0 :(得分:0)
我正在从会话中加载客户,并没有提供正确的模型作为参数,对于那些也在寻找这个答案的人来说;
$customer = Mage::getModel('customer/customer')->loadByEmail(Mage::getSingleton('customer/session')->getCustomer()->getEmail());