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


PHP Mage_Shipping_Model_Rate_Request::getVendorId方法代码示例

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


在下文中一共展示了Mage_Shipping_Model_Rate_Request::getVendorId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
 {
     $vendorId = $request->getVendorId();
     if (!$this->getConfigFlag('active')) {
         return false;
     }
     $result = Mage::getModel('shipping/rate_result');
     $freeMethod = $this->getFreeShippingMethodByVendor($vendorId);
     $isFreeShip = false;
     if (!empty($freeMethod)) {
         $orderAmount = $this->getOrderAmount($request);
         if ($orderAmount >= $freeMethod->getOrderAmountLimit()) {
             $method = Mage::getModel('shipping/rate_result_method');
             $method->setCarrier($this->_code);
             $method->setCarrierTitle($this->getConfigData('title'));
             $method->setMethod('rate' . $freeMethod->getId());
             $method->setMethodTitle($freeMethod->getTitle());
             $method->setMethodDescription($freeMethod->getDescription());
             $shippingPrice = 0;
             $method->setPrice($shippingPrice);
             $method->setCost($shippingPrice);
             $result->append($method);
             $isFreeShip = true;
         }
     }
     if (!$isFreeShip) {
         $rates = Mage::getResourceModel('smdropship/shipping_multiflatrate_collection')->addNoFreeToFilter();
         foreach ($rates as $rate) {
             if ($rate->getActive() && in_array($vendorId, $rate->getVendorIds())) {
                 $method = Mage::getModel('shipping/rate_result_method');
                 $method->setCarrier($this->_code);
                 $method->setCarrierTitle($this->getConfigData('title'));
                 $method->setMethod('rate' . $rate->getId());
                 $method->setMethodTitle($rate->getTitle());
                 $method->setMethodDescription($rate->getDescription());
                 $shippingPrice = $rate->getPrice();
                 $method->setPrice($shippingPrice);
                 $method->setCost($shippingPrice);
                 $result->append($method);
             }
         }
     }
     return $result;
 }
开发者ID:shashankkanungo,项目名称:magento,代码行数:50,代码来源:Multiflatrate.php

示例2: _collectRates

 protected function _collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$this->getConfigFlag('active')) {
         return false;
     }
     $items = $request->getAllItems();
     $hlpd = Mage::helper('udropship/protected');
     $tsHlp = Mage::helper('udtiership');
     $quote = Mage::helper('udropship/item')->getQuote($items);
     $address = Mage::helper('udropship/item')->getAddress($items);
     if ($hasShipClass = Mage::helper('udropship')->isModuleActive('udshipclass')) {
         $vscId = Mage::helper('udshipclass')->getVendorShipClass($request->getVendorId());
         $cscId = Mage::helper('udshipclass')->getCustomerShipClass($address);
     }
     $vId = $request->getVendorId();
     $store = $quote->getStore();
     $locale = Mage::app()->getLocale();
     $tierRates = $vId ? $this->getTiershipRates($vId) : array();
     $vendor = $vId ? Mage::helper('udropship')->getVendor($vId) : new Varien_Object();
     $globalTierRates = $this->getGlobalTierShipConfig();
     $rateReq = new Unirgy_DropshipTierShipping_Model_RateReq(array('data_object' => new Varien_Object($tierRates), 'global_data_object' => new Varien_Object($globalTierRates), 'store' => $store, 'vendor' => $vendor, 'locale' => $locale));
     $topCats = $tsHlp->getTopCategories();
     $catIdsToLoad = $catIds = array();
     foreach ($request->getAllItems() as $item) {
         if ($item->getParentItem()) {
             continue;
         }
         $product = $item->getProduct();
         $_catIds = $product->getCategoryIds();
         if (empty($_catIds)) {
             continue;
         }
         reset($_catIds);
         $catIdsToLoad = array_merge($catIdsToLoad, $_catIds);
         $catIds[$item->getId()] = $_catIds;
     }
     $catIdsToLoad = array_unique($catIdsToLoad);
     $iCats = Mage::getResourceModel('catalog/category_collection')->addIdFilter($catIdsToLoad);
     $subcatMatchFlag = Mage::getStoreConfigFlag('carriers/udtiership/match_subcategories');
     $ratesToUse = $ratesByHandling = $ratesByCost = array();
     foreach ($request->getAllItems() as $item) {
         if ($item->getParentItem()) {
             continue;
         }
         $product = $item->getProduct();
         $pId = $product->getId();
         $rateReq->setProduct($product);
         $_rateToUse = false;
         if (!empty($ratesToUse[$pId])) {
             $ratesToUse[$pId]->setItemQty($ratesToUse[$pId]->getItemQty() + $this->getItemCalculationQty($item));
             continue;
         }
         if (!empty($catIds[$item->getId()])) {
             $exactMatched = $subcatMatched = false;
             foreach ($catIds[$item->getId()] as $iCatId) {
                 if (!($iCat = $iCats->getItemById($iCatId))) {
                     continue;
                 }
                 $_exactMatched = $_subcatMatched = false;
                 $_exactMatched = $topCats->getItemById($iCatId);
                 $catId = null;
                 if ($_exactMatched) {
                     $catId = $iCatId;
                 } elseif ($subcatMatchFlag) {
                     $_catPath = explode(',', Mage::helper('udropship/catalog')->getPathInStore($iCat));
                     foreach ($_catPath as $_catPathId) {
                         if ($topCats->getItemById($_catPathId)) {
                             $catId = $_catPathId;
                             $_subcatMatched = true;
                             break;
                         }
                     }
                 }
                 if ($catId && $topCats->getItemById($catId) && ($_exactMatched || !$exactMatched && !$_rateToUse)) {
                     $rateReq->initKey($catId, $vscId, $cscId);
                     $rateReq->setSubkeys(array('cost', 'additional', 'handling'));
                     $_rateToUse = $rateReq->getResult();
                 }
                 $exactMatched = $exactMatched || $_exactMatched;
                 $subcatMatched = $subcatMatched || $_subcatMatched;
             }
         }
         if ($_rateToUse) {
             $_rateToUse->setData('item_qty', $this->getItemCalculationQty($item));
             $ratesToUse[$pId] = $_rateToUse;
             $groupId = $_rateToUse->getCategoryId();
             if ($_rateToUse->isProductRate('cost')) {
                 $groupId = 'product' . $pId;
             } elseif ($_rateToUse->isFallbackRate('cost')) {
                 $groupId = 'fallback';
             }
             $ratesByCost[$groupId][] = $_rateToUse;
             $hGroupId = $_rateToUse->getCategoryId();
             if ($_rateToUse->isProductRate('handling')) {
                 $hGroupId = 'product' . $pId;
             } elseif ($_rateToUse->isFallbackRate('handling')) {
                 $hGroupId = 'fallback';
             }
             $ratesByHandling[$hGroupId][] = $_rateToUse;
             if (!isset($maxCost) || $maxCost < $_rateToUse->getData('cost')) {
//.........这里部分代码省略.........
开发者ID:xiaoguizhidao,项目名称:magento,代码行数:101,代码来源:Carrier.php


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