0
定製運輸方式的報價,我想以編程方式創建銷售訂單使用引號用我自己定製的送貨方式,送貨價格&標題銷售訂單。編程方式創建一個使用與在Magento
這是我的自定義的運輸方式模型:
<?php
class Mycompany_Mymodule_Model_Carrier
extends Mage_Shipping_Model_Carrier_Abstract
implements Mage_Shipping_Model_Carrier_Interface
{
protected $_code = 'icw_shipping';
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!Mage::registry($this->_code)) {
return false;
}
$info = Mage::registry($this->_code);
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier($this->_code);
$method->setMethod($this->_code);
$method->setCarrierTitle($info['shippingCarrier']);
$method->setMethodTitle($info['shippingTitle']);
$method->setPrice($info['shippingPrice']);
$method->setCost($info['shippingPrice']);
$result = Mage::getModel('shipping/rate_result');
$result->append($method);
Mage::unregister($this->_code);
return $result;
}
public function getAllowedMethods()
{
return array(
$this->_code => 'ICW Shipping',
);
}
}
我嘗試使用這樣的:
// Method to save sales order quote
private function saveSalesOrderQuote()
{
Mage::register($this->_settings['ShippingMethod'], array(
'shippingCarrier' => 'Custom',
'shippingTitle' => $this->_orderData->ShippingMethod,
'shippingPrice' => $this->_orderData->ShippingAmount
));
$this->_quote->getShippingAddress()->setShippingMethod(
$this->_settings['ShippingMethod']
);
$this->_quote->getShippingAddress()->setCollectShippingRates(
true
);
$this->_quote->getShippingAddress()->collectShippingRates();
$this->_quote->collectTotals();
$this->_quote->reserveOrderId();
$this->_quote->save();
}
但它似乎並不奏效。訂單創建時,一切正確的期望的運輸方式,標題&價格。這是我看到在後端:
這裏是我完整的代碼至今:http://pastebin.com/jUTM0VbD
任何想法,我做錯了什麼?如何使用我自己的自定義送貨方式並設置自定義價格和標題?