【发布时间】:2013-05-08 13:41:19
【问题描述】:
我已经为运输方式集成了矩阵费率模块。但是我有额外的要求
用于通过更改仓库选项来显示动态运费。
例如,我有2个仓库A和B。当用户选择仓库A时,那么
运费应相应更新。和仓库 B 一样。
我很困惑我该怎么做?
请帮忙。
【问题讨论】:
我已经为运输方式集成了矩阵费率模块。但是我有额外的要求
用于通过更改仓库选项来显示动态运费。
例如,我有2个仓库A和B。当用户选择仓库A时,那么
运费应相应更新。和仓库 B 一样。
我很困惑我该怎么做?
请帮忙。
【问题讨论】:
我正在为类似的要求而苦苦挣扎。我必须根据用户选择的邮资方式来设置运费。
如果对您有帮助,我将按照以下方式进行:
创建一个自定义运输方式,让用户选择仓库/邮资/其他。它应显示在 OnePageCheckout 运输方法步骤中。您可以轻松创建新的送货方式,只需 Google 一下即可。
在 template/checkout/shipping_method/available.phtml 中加入 if($_rate->getCode()=='yourmodule_code') 条件
然后为用户可以看到的单选按钮编写代码。例如。仓库 1 和仓库 2。
根据用户选择,使用您的模块的 collectRates() 方法[您已覆盖] 设置运费,如下所示
public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
$result = Mage::getModel('shipping/rate_result');
if($show){
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier($this->_code);
$method->setMethod($this->_code);
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethodTitle($this->getConfigData('name'));
$method->setPrice($price); //this price you can get from available.phtml using AJAX
$method->setCost($price);
$result->append($method);
}else{
$error = Mage::getModel('shipping/rate_result_error');
$error->setCarrier($this->_code);
$error->setCarrierTitle($this->getConfigData('name'));
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
$result->append($error);
}
return $result;
}
希望对你有帮助。
【讨论】: