本文整理汇总了PHP中Mage_Shipping_Model_Rate_Request::hasFreeMethodWeight方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Shipping_Model_Rate_Request::hasFreeMethodWeight方法的具体用法?PHP Mage_Shipping_Model_Rate_Request::hasFreeMethodWeight怎么用?PHP Mage_Shipping_Model_Rate_Request::hasFreeMethodWeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Shipping_Model_Rate_Request
的用法示例。
在下文中一共展示了Mage_Shipping_Model_Rate_Request::hasFreeMethodWeight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _updateFreeMethodQuote
/**
* Override this for Shipwire. We only quote $0 shipping cost if all the items in the cart qualify for free shipping
* @param Mage_Shipping_Model_Rate_Request $request
* @return null
*/
protected function _updateFreeMethodQuote($request)
{
// echo "getFreeMethodWeight: " . $request->getFreeMethodWeight();
// echo "hasFreeMethodWeight: " . $request->hasFreeMethodWeight();
// echo "getPackageWeight: " . $request->getPackageWeight();
if ($request->getFreeMethodWeight() == $request->getPackageWeight() || !$request->hasFreeMethodWeight()) {
return;
}
$freeMethod = $this->getConfigData($this->_freeMethod);
if (!$freeMethod) {
return;
}
$freeRateId = false;
if (is_object($this->_result)) {
foreach ($this->_result->getAllRates() as $i => $item) {
if ($item->getMethod() == $freeMethod) {
$freeRateId = $i;
break;
}
}
}
if ($freeRateId === false) {
return;
}
if ($request->getFreeMethodWeight() == 0) {
// If the entire order has no weight because it is free then set the price to 0
$this->_result->getRateById($freeRateId)->setPrice(0);
}
}
示例2: _updateFreeMethodQuote
/**
* @param Mage_Shipping_Model_Rate_Request $request
* @return null
*/
protected function _updateFreeMethodQuote($request)
{
if ($request->getFreeMethodWeight() == $request->getPackageWeight() || !$request->hasFreeMethodWeight()) {
return;
}
$freeMethod = $this->getConfigData('free_method');
if (!$freeMethod) {
return;
}
$freeRateId = false;
if (is_object($this->_result)) {
foreach ($this->_result->getAllRates() as $i => $item) {
if ($item->getMethod() == $freeMethod) {
$freeRateId = $i;
break;
}
}
}
if ($freeRateId === false) {
return;
}
$price = null;
if ($request->getFreeMethodWeight() > 0) {
$this->_setFreeMethodRequest($freeMethod);
$result = $this->_getQuotes();
if ($result && ($rates = $result->getAllRates()) && count($rates) > 0) {
if (count($rates) == 1 && $rates[0] instanceof Mage_Shipping_Model_Rate_Result_Method) {
$price = $rates[0]->getPrice();
}
if (count($rates) > 1) {
foreach ($rates as $rate) {
if ($rate instanceof Mage_Shipping_Model_Rate_Result_Method && $rate->getMethod() == $freeMethod) {
$price = $rate->getPrice();
}
}
}
}
} else {
/**
* if we can apply free shipping for all order we should force price
* to $0.00 for shipping with out sending second request to carrier
*/
$price = 0;
}
/**
* if we did not get our free shipping method in response we must use its old price
*/
if (!is_null($price)) {
$this->_result->getRateById($freeRateId)->setPrice($price);
}
}
示例3: _updateFreeMethodQuote
/**
* WebShopApps - Changed to support Free Shipping using either Ground or Home Delivery
* @param Mage_Shipping_Model_Rate_Request $request
* @return null
*/
protected function _updateFreeMethodQuote($request)
{
if ($request->getFreeMethodWeight() == $request->getPackageWeight() || !$request->hasFreeMethodWeight()) {
return;
}
$freeCode = Mage::helper('wsacommon')->getNewVersion() < 12 ? 'free_method' : $this->_freeMethod;
$freeMethod = $this->getConfigData($freeCode);
if (!$freeMethod) {
return;
}
$freeRateId = false;
$matchFedexGround = false;
if ($this->getConfigData('free_both_ground')) {
if ($freeMethod == 'GROUND_HOME_DELIVERY') {
$altMethod = 'FEDEX_GROUND';
$matchFedexGround = true;
} else {
if ($freeMethod == 'FEDEX_GROUND') {
// could match on either, need to check
$altMethod = 'GROUND_HOME_DELIVERY';
$matchFedexGround = true;
}
}
}
if (is_object($this->_result)) {
foreach ($this->_result->getAllRates() as $i => $item) {
if ($item->getMethod() == $freeMethod || $matchFedexGround && $item->getMethod() == $altMethod) {
$freeRateId = $i;
break;
}
}
}
if ($freeRateId === false) {
return;
}
$price = null;
if ($request->getFreeMethodWeight() > 0) {
$this->_setFreeMethodRequest($freeMethod);
$result = $this->_getQuotes();
if ($result && ($rates = $result->getAllRates()) && count($rates) > 0) {
if (count($rates) == 1 && $rates[0] instanceof Mage_Shipping_Model_Rate_Result_Method) {
$price = $rates[0]->getPrice();
}
if (count($rates) > 1) {
foreach ($rates as $rate) {
if ($rate instanceof Mage_Shipping_Model_Rate_Result_Method && ($rate->getMethod() == $freeMethod || $matchFedexGround && $item->getMethod() == $altMethod)) {
$price = $rate->getPrice();
}
}
}
}
} else {
/**
* if we can apply free shipping for all order we should force price
* to $0.00 for shipping with out sending second request to carrier
*/
$price = 0;
}
/**
* if we did not get our free shipping method in response we must use its old price
*/
if (!is_null($price)) {
$this->_result->getRateById($freeRateId)->setPrice($price);
}
}