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


PHP Mage_Shipping_Model_Rate_Request::getStoreId方法代码示例

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


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

示例1: collectRates

 /**
  * Collect rates for this shipping method based on information in $request
  *
  * @param Mage_Shipping_Model_Rate_Request $data
  * @return Mage_Shipping_Model_Rate_Result
  */
 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$this->getConfigData('active')) {
         return false;
     }
     $result = Mage::getModel('shipping/rate_result');
     $collection = Mage::getResourceModel('amtable/method_collection')->addFieldToFilter('is_active', 1)->addStoreFilter($request->getStoreId())->addCustomerGroupFilter($this->getCustomerGroupId($request))->setOrder('pos');
     $rates = Mage::getModel('amtable/rate')->findBy($request, $collection);
     foreach ($collection as $customMethod) {
         // create new instance of method rate
         $method = Mage::getModel('shipping/rate_result_method');
         // record carrier information
         $method->setCarrier($this->_code);
         $method->setCarrierTitle($this->getConfigData('title'));
         // record method information
         $method->setMethod($this->_code . $customMethod->getId());
         $method->setMethodTitle(Mage::helper('amtable')->__($customMethod->getName()));
         if (isset($rates[$customMethod->getId()])) {
             $method->setCost($rates[$customMethod->getId()]);
             $method->setPrice($rates[$customMethod->getId()]);
             // add this rate to the result
             $result->append($method);
         }
     }
     return $result;
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:32,代码来源:Table.php

示例2: collectRatesWithAddress

 /**
  * Retrieve all methods for supplied shipping data
  *
  * @todo make it ordered
  * @param Mage_Shipping_Model_Shipping_Method_Request $data
  * @return Mage_Shipping_Model_Shipping
  */
 public function collectRatesWithAddress(Mage_Shipping_Model_Rate_Request $request, $address)
 {
     $storeId = $request->getStoreId();
     if (!$request->getOrig()) {
         $request->setCountryId(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_COUNTRY_ID, $storeId))->setRegionId(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_REGION_ID, $storeId))->setCity(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_CITY, $storeId))->setPostcode(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_POSTCODE, $storeId));
     }
     $limitCarrier = $request->getLimitCarrier();
     if (!$limitCarrier) {
         $carriers = Mage::getStoreConfig('carriers', $storeId);
         foreach ($carriers as $carrierCode => $carrierConfig) {
             $this->collectCarrierRatesWithAddress($carrierCode, $request, $address);
         }
     } else {
         if (!is_array($limitCarrier)) {
             $limitCarrier = array($limitCarrier);
         }
         foreach ($limitCarrier as $carrierCode) {
             $carrierConfig = Mage::getStoreConfig('carriers/' . $carrierCode, $storeId);
             if (!$carrierConfig) {
                 continue;
             }
             $this->collectCarrierRatesWithAddress($carrierCode, $request, $address);
         }
     }
     return $this;
 }
开发者ID:gino2014,项目名称:Quanbit_QBShippingAndPaymentFilters,代码行数:33,代码来源:Shipping.php

示例3: collectRates2

 public function collectRates2(Mage_Shipping_Model_Rate_Request $request)
 {
     $storeId = $request->getStoreId();
     if (!$request->getOrig()) {
         $request->setCountryId(Mage::getStoreConfig(self::XML_PATH_STORE_COUNTRY_ID, $request->getStore()))->setRegionId(Mage::getStoreConfig(self::XML_PATH_STORE_REGION_ID, $request->getStore()))->setCity(Mage::getStoreConfig(self::XML_PATH_STORE_CITY, $request->getStore()))->setPostcode(Mage::getStoreConfig(self::XML_PATH_STORE_ZIP, $request->getStore()));
     }
     $limitCarrier = $request->getLimitCarrier();
     $carriers = Mage::getStoreConfig('carriers', $storeId);
     foreach ($carriers as $carrierCode => $carrierConfig) {
         if (!in_array($carrierCode, $limitCarrier)) {
             $this->collectCarrierRates($carrierCode, $request);
         }
         //echo $carrierCode;
     }
     return $this;
 }
开发者ID:shashankkanungo,项目名称:magento,代码行数:16,代码来源:SM_Dropship_Model_Override_Shipping_Shipping.php

示例4: setRequest

 /**
  * Prepare and set request to this instance
  *
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return Mage_Usa_Model_Shipping_Carrier_Fedex
  */
 public function setRequest(Mage_Shipping_Model_Rate_Request $request)
 {
     $this->_request = $request;
     $r = new Varien_Object();
     if ($request->getLimitMethod()) {
         $r->setService($request->getLimitMethod());
     }
     if ($request->getFedexAccount()) {
         $account = $request->getFedexAccount();
     } else {
         $account = $this->getConfigData('account');
     }
     $r->setAccount($account);
     if ($request->getFedexDropoff()) {
         $dropoff = $request->getFedexDropoff();
     } else {
         $dropoff = $this->getConfigData('dropoff');
     }
     $r->setDropoffType($dropoff);
     if ($request->getFedexPackaging()) {
         $packaging = $request->getFedexPackaging();
     } else {
         $packaging = $this->getConfigData('packaging');
     }
     $r->setPackaging($packaging);
     if ($request->getOrigCountry()) {
         $origCountry = $request->getOrigCountry();
     } else {
         $origCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $request->getStoreId());
     }
     $r->setOrigCountry(Mage::getModel('directory/country')->load($origCountry)->getIso2Code());
     if ($request->getOrigPostcode()) {
         $r->setOrigPostal($request->getOrigPostcode());
     } else {
         $r->setOrigPostal(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, $request->getStoreId()));
     }
     if ($request->getDestCountryId()) {
         $destCountry = $request->getDestCountryId();
     } else {
         $destCountry = self::USA_COUNTRY_ID;
     }
     $r->setDestCountry(Mage::getModel('directory/country')->load($destCountry)->getIso2Code());
     if ($request->getDestPostcode()) {
         $r->setDestPostal($request->getDestPostcode());
     } else {
     }
     $weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
     $r->setWeight($weight);
     if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
         $r->setFreeMethodWeight($request->getFreeMethodWeight());
     }
     $r->setValue($request->getPackagePhysicalValue());
     $r->setValueWithDiscount($request->getPackageValueWithDiscount());
     $r->setMeterNumber($this->getConfigData('meter_number'));
     $r->setKey($this->getConfigData('key'));
     $r->setPassword($this->getConfigData('password'));
     $r->setIsReturn($request->getIsReturn());
     $r->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax());
     $this->_rawRequest = $r;
     return $this;
 }
开发者ID:sshegde123,项目名称:wmp8,代码行数:67,代码来源:Fedex.php

示例5: setRequest

 /**
  * Prepare and set request to this instance
  *
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return Mage_Usa_Model_Shipping_Carrier_Usps
  */
 public function setRequest(Mage_Shipping_Model_Rate_Request $request)
 {
     $this->_request = $request;
     $r = new Varien_Object();
     if ($request->getLimitMethod()) {
         $r->setService($request->getLimitMethod());
     } else {
         $r->setService('ALL');
     }
     if ($request->getUspsUserid()) {
         $userId = $request->getUspsUserid();
     } else {
         $userId = $this->getConfigData('userid');
     }
     $r->setUserId($userId);
     if ($request->getUspsContainer()) {
         $container = $request->getUspsContainer();
     } else {
         $container = $this->getConfigData('container');
     }
     $r->setContainer($container);
     if ($request->getUspsSize()) {
         $size = $request->getUspsSize();
     } else {
         $size = $this->getConfigData('size');
     }
     $r->setSize($size);
     if ($request->getGirth()) {
         $girth = $request->getGirth();
     } else {
         $girth = $this->getConfigData('girth');
     }
     $r->setGirth($girth);
     if ($request->getHeight()) {
         $height = $request->getHeight();
     } else {
         $height = $this->getConfigData('height');
     }
     $r->setHeight($height);
     if ($request->getLength()) {
         $length = $request->getLength();
     } else {
         $length = $this->getConfigData('length');
     }
     $r->setLength($length);
     if ($request->getWidth()) {
         $width = $request->getWidth();
     } else {
         $width = $this->getConfigData('width');
     }
     $r->setWidth($width);
     if ($request->getUspsMachinable()) {
         $machinable = $request->getUspsMachinable();
     } else {
         $machinable = $this->getConfigData('machinable');
     }
     $r->setMachinable($machinable);
     if ($request->getOrigPostcode()) {
         $r->setOrigPostal($request->getOrigPostcode());
     } else {
         $r->setOrigPostal(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, $request->getStoreId()));
     }
     if ($request->getOrigCountryId()) {
         $r->setOrigCountryId($request->getOrigCountryId());
     } else {
         $r->setOrigCountryId(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $request->getStoreId()));
     }
     if ($request->getDestCountryId()) {
         $destCountry = $request->getDestCountryId();
     } else {
         $destCountry = self::USA_COUNTRY_ID;
     }
     $r->setDestCountryId($destCountry);
     if (!$this->_isUSCountry($destCountry)) {
         $r->setDestCountryName($this->_getCountryName($destCountry));
     }
     if ($request->getDestPostcode()) {
         $r->setDestPostal($request->getDestPostcode());
     }
     $weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
     $r->setWeightPounds(floor($weight));
     $r->setWeightOunces(round(($weight - floor($weight)) * self::OUNCES_POUND, 1));
     if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
         $r->setFreeMethodWeight($request->getFreeMethodWeight());
     }
     $r->setValue($request->getPackageValue());
     $r->setValueWithDiscount($request->getPackageValueWithDiscount());
     $r->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax());
     $this->_rawRequest = $r;
     return $this;
 }
开发者ID:nja78,项目名称:Magento-Pre-Patched-Files,代码行数:97,代码来源:Usps.php

示例6: setRequest

 public function setRequest(Mage_Shipping_Model_Rate_Request $request)
 {
     $this->_request = $request;
     $r = new Varien_Object();
     $r->setStoreId($request->getStoreId());
     if ($request->getLimitMethod()) {
         $r->setService($request->getLimitMethod());
     }
     if ($request->getDhlId()) {
         $id = $request->getDhlId();
     } else {
         $id = $this->getConfigData('id');
     }
     $r->setId($id);
     if ($request->getDhlPassword()) {
         $password = $request->getDhlPassword();
     } else {
         $password = $this->getConfigData('password');
     }
     $r->setPassword($password);
     if ($request->getDhlAccount()) {
         $accountNbr = $request->getDhlAccount();
     } else {
         $accountNbr = $this->getConfigData('account');
     }
     $r->setAccountNbr($accountNbr);
     if ($request->getDhlShippingKey()) {
         $shippingKey = $request->getDhlShippingKey();
     } else {
         $shippingKey = $this->getConfigData('shipping_key');
     }
     $r->setShippingKey($shippingKey);
     if ($request->getDhlShippingIntlKey()) {
         $shippingKey = $request->getDhlShippingIntlKey();
     } else {
         $shippingKey = $this->getConfigData('shipping_intlkey');
     }
     $r->setShippingIntlKey($shippingKey);
     if ($request->getDhlShipmentType()) {
         $shipmentType = $request->getDhlShipmentType();
     } else {
         $shipmentType = $this->getConfigData('shipment_type');
     }
     $r->setShipmentType($shipmentType);
     if ($request->getDhlDutiable()) {
         $shipmentDutible = $request->getDhlDutiable();
     } else {
         $shipmentDutible = $this->getConfigData('dutiable');
     }
     $r->setDutiable($shipmentDutible);
     if ($request->getDhlDutyPaymentType()) {
         $dutypaytype = $request->getDhlDutyPaymentType();
     } else {
         $dutypaytype = $this->getConfigData('dutypaymenttype');
     }
     $r->setDutyPaymentType($dutypaytype);
     if ($request->getDhlContentDesc()) {
         $contentdesc = $request->getDhlContentDesc();
     } else {
         $contentdesc = $this->getConfigData('contentdesc');
     }
     $r->setContentDesc($contentdesc);
     if ($request->getDestPostcode()) {
         $r->setDestPostal($request->getDestPostcode());
     }
     if ($request->getOrigCountry()) {
         $origCountry = $request->getOrigCountry();
     } else {
         $origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
     }
     $r->setOrigCountry($origCountry);
     /*
      * DHL only accepts weight as a whole number. Maximum length is 3 digits.
      */
     $weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
     $shippingWeight = round(max(1, $weight), 0);
     $r->setValue(round($request->getPackageValue(), 2));
     $r->setValueWithDiscount($request->getPackageValueWithDiscount());
     $r->setDestStreet(Mage::helper('core/string')->substr($request->getDestStreet(), 0, 35));
     $r->setDestCity($request->getDestCity());
     if ($request->getDestCountryId()) {
         $destCountry = $request->getDestCountryId();
     } else {
         $destCountry = self::USA_COUNTRY_ID;
     }
     //for DHL, puero rico state for US will assume as puerto rico country
     //for puerto rico, dhl will ship as international
     if ($destCountry == self::USA_COUNTRY_ID && ($request->getDestPostcode() == '00912' || $request->getDestRegionCode() == self::PUERTORICO_COUNTRY_ID)) {
         $destCountry = self::PUERTORICO_COUNTRY_ID;
     }
     $r->setDestCountryId($destCountry);
     $r->setDestState($request->getDestRegionCode());
     $r->setWeight($shippingWeight);
     $r->setFreeMethodWeight($request->getFreeMethodWeight());
     $this->_rawRequest = $r;
     //        $methods = explode(',', $this->getConfigData('allowed_methods'));
     //
     //        $freeMethod = $this->getConfigData('free_method');
     //
     //        $internationcode = $this->getCode('international_searvice');
//.........这里部分代码省略.........
开发者ID:HelioFreitas,项目名称:magento-pt_br,代码行数:101,代码来源:Dhl.php

示例7: collectRates

 /**
  * Retrieve all methods for supplied shipping data
  *
  * @todo make it ordered
  * @param Mage_Shipping_Model_Shipping_Method_Request $data
  * @return Mage_Shipping_Model_Shipping
  */
 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$request->getOrig()) {
         $request->setCountryId(Mage::getStoreConfig('shipping/origin/country_id', $request->getStore()))->setRegionId(Mage::getStoreConfig('shipping/origin/region_id', $request->getStore()))->setCity(Mage::getStoreConfig('shipping/origin/city', $request->getStore()))->setPostcode(Mage::getStoreConfig('shipping/origin/postcode', $request->getStore()));
     }
     $limitCarrier = $request->getLimitCarrier();
     if (!$limitCarrier) {
         $carriers = Mage::getStoreConfig('carriers', $request->getStoreId());
         foreach ($carriers as $carrierCode => $carrierConfig) {
             $this->collectCarrierRates($carrierCode, $request);
         }
     } else {
         if (!is_array($limitCarrier)) {
             $limitCarrier = array($limitCarrier);
         }
         foreach ($limitCarrier as $carrierCode) {
             $carrierConfig = Mage::getStoreConfig('carriers/' . $carrierCode, $request->getStoreId());
             if (!$carrierConfig) {
                 continue;
             }
             $this->collectCarrierRates($carrierCode, $request);
         }
     }
     return $this;
 }
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:32,代码来源:Shipping.php

示例8: getRate

 public function getRate(Mage_Shipping_Model_Rate_Request $request)
 {
     $read = $this->_getReadAdapter();
     $postcode = $request->getDestPostcode();
     $table = $this->getMainTable();
     $storeId = $request->getStoreId();
     $insuranceStep = (double) Mage::getStoreConfig('carriers/eparcel/insurance_step', $storeId);
     $insuranceCostPerStep = (double) Mage::getStoreConfig('carriers/eparcel/insurance_cost_per_step', $storeId);
     $signatureRequired = Mage::getStoreConfigFlag('carriers/eparcel/signature_required', $storeId);
     if ($signatureRequired) {
         $signatureCost = (double) Mage::getStoreConfig('carriers/eparcel/signature_cost', $storeId);
     } else {
         $signatureCost = 0;
     }
     for ($j = 0; $j < 5; $j++) {
         $select = $read->select()->from($table);
         // Support for Multi Warehouse Extension.
         if ($request->getWarehouseId() > 0) {
             $select->where('stock_id = ?', $request->getWarehouseId());
         }
         switch ($j) {
             case 0:
                 $select->where($read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()) . $read->quoteInto(" AND dest_region_id=? ", $request->getDestRegionId()) . $read->quoteInto(" AND dest_zip=?) ", $postcode));
                 break;
             case 1:
                 $select->where($read->quoteInto("  (dest_country_id=? ", $request->getDestCountryId()) . $read->quoteInto(" AND dest_region_id=? AND dest_zip='0000') ", $request->getDestRegionId()));
                 break;
             case 2:
                 $select->where($read->quoteInto("  (dest_country_id=? AND dest_region_id='0' AND dest_zip='0000') ", $request->getDestCountryId()));
                 break;
             case 3:
                 $select->where($read->quoteInto("  (dest_country_id=? AND dest_region_id='0' ", $request->getDestCountryId()) . $read->quoteInto("  AND dest_zip=?) ", $postcode));
                 break;
             case 4:
                 $select->where("  (dest_country_id='0' AND dest_region_id='0' AND dest_zip='0000')");
                 break;
         }
         if (is_array($request->getConditionName())) {
             $i = 0;
             foreach ($request->getConditionName() as $conditionName) {
                 if ($i == 0) {
                     $select->where('condition_name=?', $conditionName);
                 } else {
                     $select->orWhere('condition_name=?', $conditionName);
                 }
                 $select->where('condition_from_value<=?', $request->getData($conditionName));
                 $select->where('condition_to_value>=?', $request->getData($conditionName));
                 $i++;
             }
         } else {
             $select->where('condition_name=?', $request->getConditionName());
             $select->where('condition_from_value<=?', $request->getData($request->getConditionName()));
             $select->where('condition_to_value>=?', $request->getData($request->getConditionName()));
         }
         $select->where('website_id=?', $request->getWebsiteId());
         $select->order('dest_country_id DESC');
         $select->order('dest_region_id DESC');
         $select->order('dest_zip DESC');
         $select->order('condition_from_value DESC');
         // pdo has an issue. we cannot use bind
         $newdata = array();
         $row = $read->fetchAll($select);
         if (!empty($row) && $j < 5) {
             // have found a result or found nothing and at end of list!
             foreach ($row as $data) {
                 try {
                     $price = (double) $data['price'];
                     // add per-Kg cost
                     $conditionValue = (double) $request->getData($request->getConditionName());
                     $price += (double) $data['price_per_kg'] * $conditionValue;
                     // add signature cost
                     $price += $signatureCost;
                     // add version without insurance
                     $data['price'] = (string) $price;
                     $newdata[] = $data;
                     if (Mage::getStoreConfig('carriers/eparcel/insurance_enable', $storeId)) {
                         // add version with insurance
                         // work out how many insurance 'steps' we have
                         $steps = ceil($request->getPackageValue() / $insuranceStep);
                         // add on number of 'steps' multiplied by the
                         // insurance cost per step
                         $insuranceCost = $insuranceCostPerStep * $steps;
                         $price += $insuranceCost;
                         $data['price'] = (string) $price;
                         $data['delivery_type'] .= " with TransitCover";
                         $newdata[] = $data;
                     }
                 } catch (Exception $e) {
                     Mage::log($e->getMessage());
                 }
             }
             break;
         }
     }
     return $newdata;
 }
开发者ID:Zookal,项目名称:fontis_australia,代码行数:96,代码来源:Eparcel.php

示例9: collectCarrierRates

 /**
  * Collect rates of given carrier
  *
  * @param string                           $carrierCode
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return Mage_Shipping_Model_Shipping
  */
 public function collectCarrierRates($carrierCode, $request)
 {
     /* @var $carrier Mage_Shipping_Model_Carrier_Abstract */
     $carrier = $this->getCarrierByCode($carrierCode, $request->getStoreId());
     if (!$carrier) {
         return $this;
     }
     $carrier->setActiveFlag($this->_availabilityConfigField);
     $result = $carrier->checkAvailableShipCountries($request);
     if (false !== $result && !$result instanceof Mage_Shipping_Model_Rate_Result_Error) {
         $result = $carrier->proccessAdditionalValidation($request);
     }
     /*
      * Result will be false if the admin set not to show the shipping module
      * if the delivery country is not within specific countries
      */
     if (false !== $result) {
         if (!$result instanceof Mage_Shipping_Model_Rate_Result_Error) {
             if ($carrier->getConfigData('shipment_requesttype')) {
                 $packages = $this->composePackagesForCarrier($carrier, $request);
                 if (!empty($packages)) {
                     $sumResults = array();
                     foreach ($packages as $weight => $packageCount) {
                         //clone carrier for multi-requests
                         $carrierObj = clone $carrier;
                         $request->setPackageWeight($weight);
                         $result = $carrierObj->collectRates($request);
                         if (!$result) {
                             return $this;
                         } else {
                             $result->updateRatePrice($packageCount);
                         }
                         $sumResults[] = $result;
                     }
                     if (!empty($sumResults) && count($sumResults) > 1) {
                         $result = array();
                         foreach ($sumResults as $res) {
                             if (empty($result)) {
                                 $result = $res;
                                 continue;
                             }
                             foreach ($res->getAllRates() as $method) {
                                 foreach ($result->getAllRates() as $resultMethod) {
                                     if ($method->getMethod() == $resultMethod->getMethod()) {
                                         $resultMethod->setPrice($method->getPrice() + $resultMethod->getPrice());
                                         continue;
                                     }
                                 }
                             }
                         }
                     }
                 } else {
                     $result = $carrier->collectRates($request);
                 }
             } else {
                 $result = $carrier->collectRates($request);
             }
             if (!$result) {
                 return $this;
             }
         }
         if ($carrier->getConfigData('showmethod') == 0 && $result->getError()) {
             return $this;
         }
         // sort rates by price
         if (method_exists($result, 'sortRatesByPrice')) {
             $result->sortRatesByPrice();
         }
         $this->getResult()->append($result);
     }
     return $this;
 }
开发者ID:hientruong90,项目名称:ee_14_installer,代码行数:79,代码来源:Shipping.php

示例10: collectCarrierRates

 /**
  * Collect rates of given carrier
  *
  * @param string                           $carrierCode
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return Mage_Shipping_Model_Shipping
  */
 public function collectCarrierRates($carrierCode, $request)
 {
     /* @var $carrier Mage_Shipping_Model_Carrier_Abstract */
     $carrier = $this->getCarrierByCode($carrierCode, $request->getStoreId());
     if (!$carrier) {
         return $this;
     }
     $carrier->setActiveFlag($this->_availabilityConfigField);
     $result = $carrier->checkAvailableShipCountries($request);
     if (false !== $result && !$result instanceof Mage_Shipping_Model_Rate_Result_Error) {
         $result = $carrier->processAdditionalValidation($request);
     }
     /*
      * Result will be false if the admin set not to show the shipping module
      * if the delivery country is not within specific countries
      */
     if (false !== $result) {
         if (!$result instanceof Mage_Shipping_Model_Rate_Result_Error) {
             $result = $carrier->collectRates($request);
             if (!$result) {
                 return $this;
             }
         }
         if ($carrier->getConfigData('showmethod') == 0 && $result->getError()) {
             return $this;
         }
         // sort rates by price
         if (method_exists($result, 'sortRatesByPrice')) {
             $result->sortRatesByPrice();
         }
         $this->getResult()->append($result);
     }
     return $this;
 }
开发者ID:relue,项目名称:magento2,代码行数:41,代码来源:Shipping.php

示例11: collectRates

 /**
  * Retrieve all methods for supplied shipping data
  *
  * @todo make it ordered
  * @param Mage_Shipping_Model_Shipping_Method_Request $data
  * @return Mage_Shipping_Model_Shipping
  */
 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     Mage::dispatchEvent(self::$_eventPrefix . '_collectRates_before', array(self::$_eventObject => $this, 'request' => $request));
     //DROP-111
     $storeId = '';
     if (Mage::app()->getStore()->isAdmin()) {
         $storeId = $request->getStoreId();
     }
     if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Dropcommon', 'carriers/dropship/active', $storeId)) {
         if (Mage::helper('dropcommon')->calculateDropshipRates($storeId)) {
             //DROP-98
             if (!Mage::registry('dropcommon_shipmodel')) {
                 $model = Mage::getModel('dropcommon/shipping_shipping');
                 Mage::register('dropcommon_shipmodel', $model);
             }
             Mage::registry('dropcommon_shipmodel')->resetResult();
             return Mage::registry('dropcommon_shipmodel')->collectRates($request);
         }
     }
     if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Dropship', 'carriers/dropship/active', $storeId)) {
         if (Mage::helper('dropcommon')->calculateDropshipRates()) {
             //DROP-98
             if (!Mage::registry('dropship_shipmodel')) {
                 $model = Mage::getModel('dropship/shipping_shipping');
                 Mage::register('dropship_shipmodel', $model);
             }
             Mage::registry('dropship_shipmodel')->resetResult();
             return Mage::registry('dropship_shipmodel')->collectRates($request);
         }
     }
     if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Rgshipping', 'shipping/rgshipping/active')) {
         if (!Mage::registry('rgshipping_shipmodel')) {
             $model = Mage::getModel('rgshipping/shipping_shipping');
             Mage::register('rgshipping_shipmodel', $model);
         }
         Mage::registry('rgshipping_shipmodel')->resetResult();
         return Mage::registry('rgshipping_shipmodel')->collectRates($request);
     }
     if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Shipmanager', 'carriers/shipmanager/active', $storeId)) {
         if (!Mage::registry('shipmanager_shipmodel')) {
             $model = Mage::getModel('shipmanager/shipping_shipping');
             Mage::register('shipmanager_shipmodel', $model);
         }
         Mage::registry('shipmanager_shipmodel')->resetResult();
         return Mage::registry('shipmanager_shipmodel')->collectRates($request);
     }
     if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Shippingoverride2', 'shipping/shippingoverride2/active')) {
         if (!Mage::registry('override2_shipmodel')) {
             $model = Mage::getModel('shippingoverride2/shipping_shipping');
             Mage::register('override2_shipmodel', $model);
         }
         Mage::registry('override2_shipmodel')->resetResult();
         return Mage::registry('override2_shipmodel')->collectRates($request);
     }
     if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Freightrate', 'carriers/freightrate/active')) {
         if (!Mage::registry('freightrate_shipmodel')) {
             $model = Mage::getModel('freightrate/shipping_shipping');
             Mage::register('freightrate_shipmodel', $model);
         }
         Mage::registry('freightrate_shipmodel')->resetResult();
         return Mage::registry('freightrate_shipmodel')->collectRates($request);
     }
     if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Wsafreightcommon', 'shipping/wsafreightcommon/active')) {
         if (!Mage::registry('wsafreightcommon_shipmodel')) {
             $model = Mage::getModel('wsafreightcommon/shipping_shipping');
             Mage::register('wsafreightcommon_shipmodel', $model);
         }
         Mage::registry('wsafreightcommon_shipmodel')->resetResult();
         return Mage::registry('wsafreightcommon_shipmodel')->collectRates($request);
     }
     if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Estesfreight', 'carriers/estesfreight/active')) {
         if (!Mage::registry('estes_shipmodel')) {
             $model = Mage::getModel('estesfreight/shipping_shipping');
             Mage::register('estes_shipmodel', $model);
         }
         Mage::registry('estes_shipmodel')->resetResult();
         return Mage::registry('estes_shipmodel')->collectRates($request);
     }
     if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Conwayfreight', 'carriers/conwayfreight/active')) {
         if (!Mage::registry('conway_shipmodel')) {
             $model = Mage::getModel('conwayfreight/shipping_shipping');
             Mage::register('conway_shipmodel', $model);
         }
         Mage::registry('conway_shipmodel')->resetResult();
         return Mage::registry('conway_shipmodel')->collectRates($request);
     }
     if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Wsafedexfreight', 'carriers/wsafedexfreight/active')) {
         if (!Mage::registry('wsafedexfreight_shipmodel')) {
             $model = Mage::getModel('wsafedexfreight/shipping_shipping');
             Mage::register('wsafedexfreight_shipmodel', $model);
         }
         Mage::registry('wsafedexfreight_shipmodel')->resetResult();
         return Mage::registry('wsafedexfreight_shipmodel')->collectRates($request);
//.........这里部分代码省略.........
开发者ID:AleksNesh,项目名称:pandora,代码行数:101,代码来源:Shipping.php

示例12: setRequest

 /**
  * Prepare and set request to this instance
  *
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return Curkle_EasyPost_Model_Carrier_Easypost
  */
 public function setRequest(Mage_Shipping_Model_Rate_Request $request)
 {
     $this->_request = $request;
     $r = new Varien_Object();
     if ($request->getOrigCountry()) {
         $origCountry = $request->getOrigCountry();
     } else {
         $origCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $request->getStoreId());
     }
     $r->setOrigCountry(Mage::getModel('directory/country')->load($origCountry)->getIso2Code());
     if ($request->getOrigRegionCode()) {
         $origRegionCode = $request->getOrigRegionCode();
     } else {
         $origRegionCode = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_REGION_ID, $request->getStoreId());
     }
     if (is_numeric($origRegionCode)) {
         $origRegionCode = Mage::getModel('directory/region')->load($origRegionCode)->getCode();
     }
     $r->setOrigRegionCode($origRegionCode);
     if ($request->getOrigPostcode()) {
         $r->setOrigPostal($request->getOrigPostcode());
     } else {
         $r->setOrigPostal(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, $request->getStoreId()));
     }
     if ($request->getOrigCity()) {
         $r->setOrigCity($request->getOrigCity());
     } else {
         $r->setOrigCity(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_CITY, $request->getStoreId()));
     }
     if ($request->getDestCountryId()) {
         $destCountry = $request->getDestCountryId();
     } else {
         $destCountry = self::USA_COUNTRY_ID;
     }
     $r->setDestCountry(Mage::getModel('directory/country')->load($destCountry)->getIso2Code());
     $r->setDestRegionCode($request->getDestRegionCode());
     if ($request->getDestPostcode()) {
         $r->setDestPostal($request->getDestPostcode());
     } else {
     }
     $weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
     $weight = $this->_getCorrectWeight($weight);
     $r->setWeight($weight);
     if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
         $r->setFreeMethodWeight($request->getFreeMethodWeight());
     }
     $r->setValue($request->getPackageValue());
     $r->setValueWithDiscount($request->getPackageValueWithDiscount());
     if ($request->getUpsUnitMeasure()) {
         $unit = $request->getUpsUnitMeasure();
     } else {
         $unit = $this->getConfigData('unit_of_measure');
     }
     $r->setUnitMeasure($unit);
     $r->setIsReturn($request->getIsReturn());
     $r->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax());
     $this->_rawRequest = $r;
     return $this;
 }
开发者ID:blackbricksoftware,项目名称:Magento-EasyPostShipping,代码行数:65,代码来源:Easypost.php

示例13: _calculateDPDPrice

 /**
  * We calculate the shipping price based on the price / rate mentioned in
  * the rates table. If a "markup_type" (percent) indicated we travel to DPD WS
  * to calculate the final price based on the shipping cost with
  * his ws. If the price / percentage is less than zero indicates that the rate is not available.
  *
  * @param array                            $rate
  * @param Mage_Shipping_Model_Rate_Request $request
  *
  * @return array|boolean
  */
 protected function _calculateDPDPrice(array $rate, Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$rate['markup_type']) {
         if ($rate['price'] >= 0) {
             return $rate['price'];
         } else {
             return false;
         }
     }
     $apiParams = $this->_getWsHelper()->getShipmentParams($request->getStoreId());
     $apiParams['method'] = Zitec_Dpd_Api_Configs::METHOD_SHIPMENT_CALCULATE_PRICE;
     try {
         $dpdApi = new Zitec_Dpd_Api($apiParams);
         $calculatePrice = $dpdApi->getApiMethodObject();
         $postCode = Mage::helper('zitec_dpd/postcode_search')->extractPostCodeForShippingRequest($request);
         $calculatePrice->setReceiverAddress($request->getDestStreet(), $request->getDestCity(), $postCode, $request->getDestCountryId())->addParcel($request->getPackageWeight())->setShipmentServiceCode($rate['method']);
         $insurance = Mage::helper('zitec_dpd')->extractInsuranceValuesByRequest($request);
         $calculatePrice = $calculatePrice->setAdditionalHighInsurance($insurance['goodsValue'], $insurance['currency'], $insurance['content']);
         $calculatePrice->execute();
     } catch (Exception $e) {
         $this->_getHelper()->log("An error occurred whilst calculating the DPD price for the shipment {$e->getMessage()}");
         return false;
     }
     $response = $calculatePrice->getCalculatePriceResponse();
     if ($response->hasError()) {
         $this->_getHelper()->log("DPD returned the following error whilst attempting to calculate the price of a shipment: {$response->getErrorText()}");
         return false;
     }
     if ($request->getBaseCurrency()->getCode() == $response->getCurrency()) {
         $dpdPrice = $response->getAmount();
     } else {
         if ($request->getBaseCurrency()->getCode() == $response->getCurrencyLocal()) {
             $dpdPrice = $response->getAmountLocal();
         } else {
             $this->_getHelper()->log("An error occurred whilst calculating the price of a shipment. The currency of the shipment ({$request->getBaseCurrency()->getCode()}) does not correspond to the currency ({$response->getCurrency()}) or the local currency ({$response->getCurrencyLocal()})  used by DPD. ");
             return false;
         }
     }
     if ($rate['markup_type'] == 1) {
         return $dpdPrice * (1 + $rate['price'] / 100);
     } else {
         return $dpdPrice + round(floatval($rate['price']), 2);
     }
 }
开发者ID:GabrielCC,项目名称:zitec-dpd-master,代码行数:55,代码来源:Dpd.php


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