注文小計に基づいて配送方法を有効/無効にする方法
-
13-12-2019 - |
質問
マゼントを学んで、カートの小計が100ドル未満の場合にのみ出荷方法を作成しようとしています。
関数getSubTotal()
でcollectRates()
を試みた後、戻り値が100より小さい場合は常にreturn false
を返します。私はそれがそのステップで計算されていなかったと思います、その真の?
そして私が欲しいものをすることができる他に何もありますか?
助けてください...ありがとうございました!
解決
あなたのcollectRates
メソッドはこの
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
//if method is disabled
if (!$this->getConfigFlag('active')) {
return false;
}
if ($request->getPackageValue() < 100) {
return false;
}
/** @var Mage_Shipping_Model_Rate_Result $result */
$result = Mage::getModel('shipping/rate_result');
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier($this->_code); //add here the payment method code
$method->setCarrierTitle($this->getConfigData('title')); //or you can add any title if it's not configurable
$method->setPrice(your shiping cost here);
$result->append($method);
return $result;
}
. 所属していません magento.stackexchange