在我的 Magento 模块中,我以编程方式创建订单。此过程在后台运行,因此在此过程中不可能与客户交互。我想使用 Magento 的采购订单付款方式,如何以编程方式插入采购订单号?不知道我的大脑是否停止工作,但我似乎找不到添加该数字的方法。带有付款方式的代码的唯一部分是这样的:
$shippingAddress->setPaymentMethod($paymentMethod);
$quote->getPayment()->importData( array('method' => $paymentMethod));
Run Code Online (Sandbox Code Playgroud)
如何在此处插入购买编号?
查看 Mage/Sales/model/Quote/Payment.php 核心代码,我发现
@method Mage_Sales_Model_Quote_Payment setPoNumber(string $value)
我认为会有帮助。
我在下面的其他功能代码中添加了 setPoNumber('PO123456') 我认为它的位置。今晚晚些时候我会测试。
公共函数PrepareConfirmOrder($customerID, $PartCart, $isHist) {
$customerObj=Mage::getModel('customer/customer')->load($customerID);
$storeId = $customerObj->getStoreId();
$quoteObj=Mage::getModel('sales/quote')->assignCustomer($customerObj);
$quoteObj->reserveOrderId();
$productModel=Mage::getModel('catalog/product');
foreach($PartCart as $part) {
foreach($part as $k=>$v) { $$k=$v; }
$productObj=$productModel->load($PartId);
$quoteItem=Mage::getModel('sales/quote_item')->setProduct($productObj);
$quoteItem->setQuote($quoteObj);
$quoteItem->setQty($qty);
$quoteItem->setOriginalCustomPrice($UnitCost) ;
$quoteObj->addItem($quoteItem);
}
$quoteObj->collectTotals();
// Add shipping method to the quote
$quoteObj->getShippingAddress()->setShippingMethod('flatrate_flatrate');
$quoteObj->getShippingAddress()->setCollectShippingRates(true)->save();
$quoteObj->save();
$quotePaymentObj=$quoteObj->getPayment();
//methods: authorizenet, paypal_express, googlecheckout, purchaseorder
$quotePaymentObj->setMethod('purchaseorder');
$quotePaymentObj->setPoNumber('PO1234567');
$quoteObj->setPayment($quotePaymentObj);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5300 次 |
| 最近记录: |