为什么某些客户无法使用某些交货方法?
-
16-10-2019 - |
题
我有4种运输方法。
旧客户只有2种方法。我已经通过另一封电子邮件创建了同一客户。它获得了所有4种运输方法。
我跳入代码和数据库表 sales_flat_quote_shipping_rate.
通过address_id进行排序,我们有:对于旧客户:2个费率记录;对于相同的新客户:4个费率记录。
为什么会发生?费率记录在哪里创建?
更新1:
我不依赖地址。这取决于产品。如果产品填补了重量,则客户将看不到某些运输方法。现在问题是为什么?)
解决方案
原因是 proccessAdditionalValidation
功能在 Mage_Shipping_Model_Carrier_Abstract
班级:
/**
* Processing additional validation to check is carrier applicable.
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return Mage_Shipping_Model_Carrier_Abstract|Mage_Shipping_Model_Rate_Result_Error|boolean
*/
public function proccessAdditionalValidation(Mage_Shipping_Model_Rate_Request $request)
{
$maxAllowedWeight = (float) $this->getConfigData('max_package_weight');
$error = null;
$showMethod = $this->getConfigData('showmethod');
foreach ($request->getAllItems() as $item) {
if ($item->getProduct() && $item->getProduct()->getId()) {
// here I got true
if ($item->getProduct()->getWeight() > $maxAllowedWeight) { $error = Mage::getModel('shipping/rate_result_error');
$error->setCarrier($this->_code)
->setCarrierTitle($this->getConfigData('title'));
$errorMsg = $this->getConfigData('specificerrmsg');
$error->setErrorMessage($errorMsg?$errorMsg:Mage::helper('shipping')->__('The shipping module is not available.'));
break;
}
}
}
if (null !== $error && $showMethod) {
return $error;
} elseif (null !== $error) {
return false;
}
return $this;
}