当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Shipping_Model_Rate_Request::setMRConditionName方法代码示例

本文整理汇总了PHP中Mage_Shipping_Model_Rate_Request::setMRConditionName方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Shipping_Model_Rate_Request::setMRConditionName方法的具体用法?PHP Mage_Shipping_Model_Rate_Request::setMRConditionName怎么用?PHP Mage_Shipping_Model_Rate_Request::setMRConditionName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Shipping_Model_Rate_Request的用法示例。


在下文中一共展示了Mage_Shipping_Model_Rate_Request::setMRConditionName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: collectRates

 /**
  * Enter description here...
  *
  * @param Mage_Shipping_Model_Rate_Request $data
  * @return Mage_Shipping_Model_Rate_Result
  */
 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$this->getConfigFlag('active')) {
         return false;
     }
     // exclude Virtual products price from Package value if pre-configured
     if (!$this->getConfigFlag('include_virtual_price') && $request->getAllItems()) {
         foreach ($request->getAllItems() as $item) {
             if ($item->getParentItem()) {
                 continue;
             }
             if ($item->getHasChildren() && $item->isShipSeparately()) {
                 foreach ($item->getChildren() as $child) {
                     if ($child->getProduct()->isVirtual() || $item->getProductType() == 'downloadable') {
                         $request->setPackageValue($request->getPackageValue() - $child->getBaseRowTotal());
                     }
                 }
             } elseif ($item->getProduct()->isVirtual() || $item->getProductType() == 'downloadable') {
                 $request->setPackageValue($request->getPackageValue() - $item->getBaseRowTotal());
             }
         }
     }
     // Free shipping by qty
     $freeQty = 0;
     if ($request->getAllItems()) {
         foreach ($request->getAllItems() as $item) {
             if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
                 continue;
             }
             if ($item->getHasChildren() && $item->isShipSeparately()) {
                 foreach ($item->getChildren() as $child) {
                     if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
                         $freeQty += $item->getQty() * ($child->getQty() - (is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0));
                     }
                 }
             } elseif ($item->getFreeShipping()) {
                 $freeQty += $item->getQty() - (is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0);
             }
         }
     }
     if (!$request->getMRConditionName()) {
         $request->setMRConditionName($this->getConfigData('condition_name') ? $this->getConfigData('condition_name') : $this->_default_condition_name);
     }
     // Package weight and qty free shipping
     $oldWeight = $request->getPackageWeight();
     $oldQty = $request->getPackageQty();
     if ($this->getConfigData('allow_free_shipping_promotions') && !$this->getConfigData('include_free_ship_items')) {
         $request->setPackageWeight($request->getFreeMethodWeight());
         $request->setPackageQty($oldQty - $freeQty);
     }
     $result = Mage::getModel('shipping/rate_result');
     $ratearray = $this->getRate($request);
     $freeShipping = false;
     if (is_numeric($this->getConfigData('free_shipping_threshold')) && $this->getConfigData('free_shipping_threshold') > 0 && $request->getPackageValue() > $this->getConfigData('free_shipping_threshold')) {
         $freeShipping = true;
     }
     if ($this->getConfigData('allow_free_shipping_promotions') && ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes())) {
         $freeShipping = true;
     }
     if ($freeShipping) {
         $method = Mage::getModel('shipping/rate_result_method');
         $method->setCarrier('matrixrate');
         $method->setCarrierTitle($this->getConfigData('title'));
         $method->setMethod('matrixrate_free');
         $method->setPrice('0.00');
         $method->setMethodTitle($this->getConfigData('free_method_text'));
         $result->append($method);
         if ($this->getConfigData('show_only_free')) {
             return $result;
         }
     }
     foreach ($ratearray as $rate) {
         if (!empty($rate) && $rate['price'] >= 0) {
             $method = Mage::getModel('shipping/rate_result_method');
             $method->setCarrier('matrixrate');
             $method->setCarrierTitle($this->getConfigData('title'));
             $method->setMethod('matrixrate_' . $rate['pk']);
             $method->setMethodTitle(Mage::helper('matrixrate')->__($rate['delivery_type']));
             $shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
             $method->setCost($rate['cost']);
             $method->setDeliveryType($rate['delivery_type']);
             $method->setPrice($shippingPrice);
             $result->append($method);
         }
     }
     return $result;
 }
开发者ID:cabrerabywaters,项目名称:magentoSunshine,代码行数:93,代码来源:Matrixrate.php


注:本文中的Mage_Shipping_Model_Rate_Request::setMRConditionName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。