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


PHP Mage_Shipping_Model_Rate_Request::getPackageWeight方法代码示例

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


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

示例1: setRequest

 /**
  * Sets the request with new values where required for shipping calculation
  *
  * @param Mage_Shipping_Model_Rate_Request $request
  */
 public function setRequest(Mage_Shipping_Model_Rate_Request $request)
 {
     $freeShippingOnly = 0;
     $this->oldWeight = $request->getPackageWeight();
     $this->oldQty = $request->getPackageQty();
     $this->oldPrice = $request->getPackageValue();
     $request->setPRConditionName($this->getConfigData('condition_name') ? $this->getConfigData('condition_name') : $this->_default_condition_name);
     $this->_rawRequest = $request;
     //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()) {
                         $request->setPackageValue($request->getPackageValue() - $child->getBaseRowTotal());
                     }
                 }
             } elseif ($item->getProduct()->isVirtual()) {
                 $request->setPackageValue($request->getPackageValue() - $item->getBaseRowTotal());
             }
         }
     }
     $this->_rawRequest->setIgnoreFreeItems(false);
 }
开发者ID:FranchuCorraliza,项目名称:magento,代码行数:32,代码来源:Premiumrate.php

示例2: _getCourierRate

 protected function _getCourierRate(Mage_Shipping_Model_Rate_Request $request)
 {
     $package_cost = $request->getPackageValueWithDiscount();
     $shipping_settings = Mage::helper('altteam_qwintry')->getShippingSettings();
     $pounds = $request->getPackageWeight();
     $currencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies();
     $currency = $request->getPackageCurrency();
     if (in_array('USD', $currencies)) {
         Mage::helper('directory')->currencyConvert($package_cost, $currency->getCurrencyCode(), 'USD');
     } elseif ($currency->getCurrencyCode() == 'EUR') {
         $package_cost = $package_cost * 1.097;
     } elseif ($currency->getCurrencyCode() == 'RMB') {
         $package_cost = $package_cost * 1.157;
     }
     $data = array('params' => array('method' => 'qwair', 'hub_code' => empty($shipping_settings['hub']) ? 'DE1' : $shipping_settings['hub'], 'insurance' => false, 'retail_pricing' => false, 'weight' => $pounds > 0.1 ? $pounds : (empty($shipping_settings['default_weight']) ? 4 : $shipping_settings['default_weight']), 'items_value' => $package_cost, 'addr_country' => $request->getDestCountryId(), 'addr_zip' => $request->getDestPostcode(), 'addr_line1' => $request->getDestStreet(), 'addr_line2' => '', 'addr_city' => $request->getDestCity(), 'addr_state' => $request->getDestRegionCode()));
     $response = Mage::helper('altteam_qwintry')->sendApiRequest('cost', $data);
     if (!$response || empty($response->success) || !$response->success) {
         return false;
     }
     $rate = Mage::getModel('shipping/rate_result_method');
     $rate->setCarrier($this->_code);
     $rate->setCarrierTitle($this->getConfigData('title'));
     $rate->setMethod('courier');
     $rate->setMethodTitle('Courier');
     $rate->setPrice($response->result->total);
     $rate->setCost(0);
     return $rate;
 }
开发者ID:qwintry,项目名称:logistics-magento,代码行数:28,代码来源:Carrier.php

示例3: collectRates

 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$this->getConfigFlag('active')) {
         //Desabilitado
         return false;
     }
     $result = Mage::getModel('shipping/rate_result');
     $error = Mage::getModel('shipping/rate_result_error');
     $error->setCarrier($this->_code);
     $error->setCarrierTitle($this->getConfigData('title'));
     $packagevalue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
     $frompcode = Mage::getStoreConfig('shipping/origin/postcode', $this->getStore());
     $topcode = $request->getDestPostcode();
     //        if(!preg_match("/^[0-9]{8}$/", $topcode))
     //        {
     //            //CEP está errado
     //            $error->setErrorMessage('O CEP está errado');
     //            $result->append($error);
     //            Mage::helper('customer')->__('Invalid ZIP CODE');
     //            return $result;
     //        }
     //die('dfgf');
     $sweight = $request->getPackageWeight();
     $method = Mage::getModel('shipping/rate_result_method');
     $method->setCarrier($this->_code);
     $method->setCarrierTitle($this->getConfigData('name'));
     $method->setMethod('sedex');
     $method->setMethodTitle('Sedex');
     $method->setPrice(10 + $this->getConfigData('handling_fee'));
     $method->setCost(10);
     $result->append($method);
     $this->_result = $result;
     $this->_updateFreeMethodQuote($request);
     return $this->_result;
 }
开发者ID:adrianomelo5,项目名称:magento,代码行数:35,代码来源:CorreioPost.php

示例4: collectRates

 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$this->getConfigFlag('active')) {
         return false;
     }
     $result = Mage::getModel('shipping/rate_result');
     $rawPostcode = $request->getDestPostcode();
     $postCode = Mage::helper('freight')->validatePostcode($rawPostcode);
     if (empty($postCode)) {
         return $result;
     }
     $packageWeight = $request->getPackageWeight();
     $shipping = Mage::getModel('freight/config')->getShippingPrice($this->_code, $postCode, $packageWeight);
     if ($shipping != null) {
         $shippingDeliveryPrice = $shipping->getData('delivery_price') / 100;
         $shippingDeliveryTime = $shipping->getData('delivery_time');
         $method = Mage::getModel('shipping/rate_result_method');
         $method->setCarrier($this->_code);
         $method->setCarrierTitle($this->getConfigData('title'));
         $method->setMethod($this->_code);
         $method->setMethodTitle($this->getConfigData('name') . Mage::helper('freight')->formatShippingTime($shippingDeliveryTime));
         $method->setPrice($shippingDeliveryPrice);
         $method->setCost($shippingDeliveryPrice);
         $result->append($method);
     }
     return $result;
 }
开发者ID:Hospeed,项目名称:gamuza_freight-magento,代码行数:27,代码来源:Abstract.php

示例5: collectRates

 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$this->isActive()) {
         return false;
     }
     $valids = $this->getConfigData('aceita');
     if ($valids == 'AMBOS') {
         $valids = array('PAC', 'Sedex');
     } else {
         $valids = array($valids);
     }
     $result = Mage::getModel('shipping/rate_result');
     $method = Mage::getModel('shipping/rate_result_method');
     $peso = $request->getPackageWeight();
     $destino = $request->getDestPostcode();
     $valor = $request->getPackageValue();
     $frete = $this->pegaFrete($peso, $destino, $valor);
     // Peso, destino, valor
     if (in_array('Sedex', $valids)) {
         $method->setCarrier($this->_code);
         $method->setCarrierTitle('PagSeguro');
         $method->setMethod($this->_code . ':Sedex');
         $method->setMethodTitle('Sedex');
         $method->setPrice($frete['Sedex']);
         $result->append($method);
     }
     // Setando valores para PAC
     if (in_array('PAC', $valids)) {
         $method = Mage::getModel('shipping/rate_result_method');
         $method->setCarrier($this->_code);
         $method->setCarrierTitle('PagSeguro');
         $method->setMethod($this->_code . ':PAC');
         $method->setMethodTitle('PAC');
         $method->setPrice($frete['PAC']);
         $result->append($method);
     }
     /*
             }else{
                 $error = Mage::getModel('shipping/rate_result_error');
                 $error->setCarrier($this->_code);
                 $error->setCarrierTitle("PagSeguro");
                 $error->setErrorMessage(utf8_encode($frete));
                 return $error;
             }*/
     return $result;
 }
开发者ID:nataliajulieta,项目名称:old,代码行数:46,代码来源:ShippingMethod.php

示例6: getRates

 /**
  * Recupera os preços de frete baseado no request do usuário
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return multitype:unknown
  */
 public function getRates(Mage_Shipping_Model_Rate_Request $request)
 {
     $read = $this->_getReadAdapter();
     $write = $this->_getWriteAdapter();
     $postcode = Mage::helper('av5_correios')->_formatZip($request->getDestPostcode());
     $table = Mage::getSingleton('core/resource')->getTableName('av5_correios_shipping/correios');
     $pkgWeight = ceil($request->getPackageWeight());
     $searchString = " AND (cep_destino_ini <= '" . $postcode . "' AND cep_destino_fim >= '" . $postcode . "') AND peso = '" . $pkgWeight . "'";
     $select = $read->select()->from($table);
     $select->where($read->quoteInto(" ( servico in (?) ) ", $request->getPostingMethods()) . $searchString);
     $newdata = array();
     $row = $read->fetchAll($select);
     if (!empty($row)) {
         foreach ($row as $data) {
             $newdata[] = $data;
         }
     }
     return $newdata;
 }
开发者ID:danielwalterrodrigues,项目名称:asus,代码行数:24,代码来源:Correios.php

示例7: collectRates

 /**
  * Collects the shipping rates for Australia Post from the REST API.
  *
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return Mage_Shipping_Model_Rate_Result|bool
  */
 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     // Check if this method is active
     if (!$this->getConfigFlag('active')) {
         return false;
     }
     // Check if this method is even applicable (shipping from Australia)
     $origCountry = Mage::getStoreConfig('shipping/origin/country_id', $request->getStore());
     if ($origCountry != 'AU') {
         return false;
     }
     if ($this->_client == null) {
         return false;
     }
     $fromPostcode = (int) Mage::getStoreConfig('shipping/origin/postcode', $this->getStore());
     $toPostcode = (int) $request->getDestPostcode();
     if ($request->getDestCountryId()) {
         $destCountry = $request->getDestCountryId();
     } else {
         $destCountry = 'AU';
     }
     $sweight = (int) $request->getPackageWeight();
     /** @var Fontis_Australia_Helper_Australiapost $helper */
     $helper = Mage::helper('australia/australiapost');
     $sheight = (int) $helper->getAttribute($request, 'height');
     $slength = (int) $helper->getAttribute($request, 'length');
     $swidth = (int) $helper->getAttribute($request, 'width');
     $extraCover = $request->getPackageValue() > self::EXTRA_COVER_LIMIT ? self::EXTRA_COVER_LIMIT : (int) $request->getPackageValue();
     $config = array('from_postcode' => $fromPostcode, 'to_postcode' => $toPostcode, 'length' => $slength, 'width' => $swidth, 'height' => $sheight, 'weight' => $sweight, 'country_code' => $destCountry);
     $this->_getQuotes($extraCover, $config);
     $_result = $this->_result->asArray();
     if (empty($_result)) {
         return false;
     }
     return $this->_result;
 }
开发者ID:vstorm83,项目名称:ausport,代码行数:42,代码来源:Australiapost.php

示例8: setBaseRequest

 public function setBaseRequest(Mage_Shipping_Model_Rate_Request $request)
 {
     $r = new Varien_Object();
     $r->setAllowedMethods($this->getConfigData('allowed_methods'));
     $r->setWeight(ceil($request->getPackageWeight() * (double) $this->getConfigData('wt_units')));
     if ($request->getOrigPostcode()) {
         $r->setOrigPostal($request->getOrigPostcode());
     } else {
         $r->setOrigPostal(Mage::getStoreConfig('shipping/origin/postcode', $this->getStore()));
     }
     if ($request->getDestCountryId()) {
         $destCountry = $request->getDestCountryId();
     } else {
         $destCountry = self::USA_COUNTRY_ID;
     }
     $r->setDestCountry(Mage::getModel('directory/country')->load($destCountry)->getIso2Code());
     $r->setDestCountryIso3(Mage::getModel('directory/country')->load($destCountry)->getIso3Code());
     $r->setDestCountryName(Mage::getModel('directory/country')->load($destCountry)->getName());
     $r->setMailClass($this->getDeliveryServiceLevel($destCountry));
     if ($request->getDestPostcode()) {
         $r->setDestPostal('US' == $r->getDestCountry() ? substr($request->getDestPostcode(), 0, 5) : $request->getDestPostcode());
     }
     return $r;
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:24,代码来源:Endicia.php

示例9: setRequest

 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->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_Config::XML_PATH_ORIGIN_POSTCODE, $this->getStore()));
     }
     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)) * 16, 1));
     if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
         $r->setFreeMethodWeight($request->getFreeMethodWeight());
     }
     $r->setValue($request->getPackageValue());
     $r->setValueWithDiscount($request->getPackageValueWithDiscount());
     $this->_rawRequest = $r;
     return $this;
 }
开发者ID:xiaoguizhidao,项目名称:emporiodopara,代码行数:61,代码来源:Usps.php

示例10: collectRates

 /**
  * Collect rate to get shipping method
  *
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return Mage_Shipping_Model_Rate_Request $request
  */
 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     $result = "";
     $ship_price = 0;
     if (!$this->getConfigFlag('active')) {
         return false;
     }
     $website_id = (int) $request->getWebsiteId();
     // Default condition Name: Weight vs. Destination
     $weight = $request->getPackageWeight();
     // Check Weight Limit
     if ($this->getConfigFlag('active_weight_limit') && $weight >= $this->getConfigData('weight_limit')) {
         return false;
     }
     // Condition Name: Price Vs. Destination
     if ($this->getConfigData('condition_name') != $this->_default_condition_name) {
         // The weight is now the price
         $weight = Mage::helper('mmshippingplus')->getOrderAmount();
     }
     // Get country, region and postcode data
     $country = Mage::helper('mmshippingplus')->getCustomerCountryCode();
     $region = Mage::helper('mmshippingplus')->getCustomerRegionCode();
     $postcode = Mage::helper('mmshippingplus')->getCustomerPostcode();
     // 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->getConditionName()) {
         $request->setConditionName($this->getConfigData('condition_name') ? $this->getConfigData('condition_name') : $this->_default_condition_name);
     }
     // Check tablerate with condition
     $tablerate = Mage::getModel('mmshippingplus/shippingplus')->getCollection()->setOrder('weight', 'DESC')->addFieldToFilter('website_id', array('in' => $website_id))->addFieldToFilter('dest_country', array('in' => array('*', $country)))->addFieldToFilter('dest_zip', array('in' => array('*', $postcode)))->addFieldToFilter('dest_region', array('in' => array('*', $region)))->addFieldToFilter('weight', array('lteq' => $weight))->addFieldToFilter('type', array('eq' => $this->getConfigData('condition_name')));
     // Tablerate price
     $ship_price = $tablerate->getFirstItem()->getPrice();
     // Price with shipping weight range
     if ($this->getConfigFlag('active_ship_kg')) {
         if ($this->getConfigData('ship_kg_country')) {
             $kg_country = explode(',', $this->getConfigData('ship_kg_country'));
         }
         $country = Mage::helper('mmshippingplus')->getCustomerCountryCode(2);
         if (in_array($country, $kg_country)) {
             if ($weight >= $this->getConfigData('ship_from_kg') && $weight <= $this->getConfigData('ship_to_kg')) {
                 $ship_price = $this->getConfigData('ship_kg_price');
             }
         }
     }
     // Price with shipping price range
     if ($this->getConfigFlag('active_ship_price')) {
         if ($this->getConfigData('ship_price_country')) {
             $price_country = explode(',', $this->getConfigData('ship_price_country'));
         }
         $country = Mage::helper('mmshippingplus')->getCustomerCountryCode(2);
         if (in_array($country, $price_country)) {
             $amount = Mage::helper('mmshippingplus')->getOrderAmount();
             if ($amount >= $this->getConfigData('ship_from_price') && $amount <= $this->getConfigData('ship_to_price')) {
                 $ship_price = $this->getConfigData('ship_price_price');
             }
         }
     }
     if (!is_null($ship_price) && $ship_price != 0) {
         // Free shipping by tablerate
         $ship_price = $ship_price == $this->_free_ship_tablerate ? 0 : $ship_price;
         // Check if price has charge
         $charge = $tablerate->getFirstItem()->getCharge();
         if ($charge > 0) {
             $amount = Mage::helper('mmshippingplus')->getOrderAmount(MMind_Shippingplus_Model_Config_Source_Rangeprice::TYPE_SUBTOTAL);
             // Charge type
             if ($this->getConfigData('charge_type') == MMind_Shippingplus_Model_Config_Source_Charge::TYPE_CHARGE_FIX) {
                 // Fix price
                 $ship_price += $charge;
             } else {
                 // Percentage price
                 $ship_price += $amount * $charge / 100;
             }
         }
         // Package weight and qty free shipping
         $oldWeight = $request->getPackageWeight();
         $oldQty = $request->getPackageQty();
         $request->setPackageWeight($request->getFreeMethodWeight());
         $request->setPackageQty($oldQty - $freeQty);
//.........这里部分代码省略.........
开发者ID:xiaoguizhidao,项目名称:MMind_Shippingplus,代码行数:101,代码来源:Shippingplus.php

示例11: _inicialCheck

 /**
  * Make initial checks and iniciate module variables
  *
  * @param Mage_Shipping_Model_Rate_Request $request Mage request
  *
  * @return bool
  */
 protected function _inicialCheck(Mage_Shipping_Model_Rate_Request $request)
 {
     $this->_prepareProductsToSendFastShipping();
     $this->_fromZip = Mage::getStoreConfig('shipping/origin/postcode', $this->getStore());
     $this->_toZip = $request->getDestPostcode();
     // Fix ZIP code
     $this->_fromZip = str_replace(array('-', '.'), '', trim($this->_fromZip));
     $this->_toZip = str_replace(array('-', '.'), '', trim($this->_toZip));
     $this->_result = Mage::getModel('shipping/rate_result');
     $this->_packageValue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
     $this->_packageWeight = number_format($request->getPackageWeight(), 2, '.', '');
     $this->_freeMethodWeight = number_format($request->getFreeMethodWeight(), 2, '.', '');
 }
开发者ID:FastShipping,项目名称:fastshipping-magento,代码行数:20,代码来源:CorreiosMethod.php

示例12: 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

示例13: _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);
     }
 }
开发者ID:hirentricore,项目名称:devmagento,代码行数:55,代码来源:Abstract.php

示例14: setRequest

 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->getUspsMachinable()) {
         $machinable = $request->getUspsMachinable();
     } else {
         $machinable = $this->getConfigData('machinable');
     }
     $r->setMachinable($machinable);
     if ($request->getOrigPostcode()) {
         $r->setOrigPostal($request->getOrigPostcode());
     } else {
         $r->setOrigPostal(Mage::getStoreConfig('shipping/origin/postcode'));
     }
     if ($request->getDestCountryId()) {
         $destCountry = $request->getDestCountryId();
     } else {
         $destCountry = self::USA_COUNTRY_ID;
     }
     $r->setDestCountryId($destCountry);
     /*
     for GB, we cannot use United Kingdom
     */
     if ($destCountry == 'GB') {
         $countryName = 'Great Britain and Northern Ireland';
     } else {
         $countries = Mage::getResourceModel('directory/country_collection')->addCountryIdFilter($destCountry)->load()->getItems();
         $country = array_shift($countries);
         $countryName = $country->getName();
     }
     $r->setDestCountryName($countryName);
     if ($request->getDestPostcode()) {
         $r->setDestPostal($request->getDestPostcode());
     }
     $weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
     $r->setWeightPounds(floor($weight));
     $r->setWeightOunces(round(($weight - floor($weight)) * 16, 1));
     if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
         $r->setFreeMethodWeight($request->getFreeMethodWeight());
     }
     $r->setValue($request->getPackageValue());
     $r->setValueWithDiscount($request->getPackageValueWithDiscount());
     $this->_rawRequest = $r;
     return $this;
 }
开发者ID:Rinso,项目名称:magento-mirror,代码行数:69,代码来源:Usps.php

示例15: _shipmentDetails

 /**
  * Generation Shipment Details Node according to origin region
  *
  * @param SimpleXMLElement $xml
  * @param Mage_Shipping_Model_Rate_Request $rawRequest
  * @param string $originRegion
  * @return void
  */
 protected function _shipmentDetails($xml, $rawRequest, $originRegion = '')
 {
     $nodeShipmentDetails = $xml->addChild('ShipmentDetails', '', '');
     $nodeShipmentDetails->addChild('NumberOfPieces', count($rawRequest->getPackages()));
     if ($originRegion) {
         $nodeShipmentDetails->addChild('CurrencyCode', Mage::app()->getWebsite($this->_request->getWebsiteId())->getBaseCurrencyCode());
     }
     $nodePieces = $nodeShipmentDetails->addChild('Pieces', '', '');
     /*
      * Package type
      * EE (DHL Express Envelope), OD (Other DHL Packaging), CP (Custom Packaging)
      * DC (Document), DM (Domestic), ED (Express Document), FR (Freight)
      * BD (Jumbo Document), BP (Jumbo Parcel), JD (Jumbo Junior Document)
      * JP (Jumbo Junior Parcel), PA (Parcel), DF (DHL Flyer)
      */
     $i = 0;
     foreach ($rawRequest->getPackages() as $package) {
         $nodePiece = $nodePieces->addChild('Piece', '', '');
         $packageType = 'EE';
         if ($package['params']['container'] == self::DHL_CONTENT_TYPE_NON_DOC) {
             $packageType = 'CP';
         }
         $nodePiece->addChild('PieceID', ++$i);
         $nodePiece->addChild('PackageType', $packageType);
         $nodePiece->addChild('Weight', round($package['params']['weight'], 1));
         $params = $package['params'];
         if ($params['width'] && $params['length'] && $params['height']) {
             if (!$originRegion) {
                 $nodePiece->addChild('Width', round($params['width']));
                 $nodePiece->addChild('Height', round($params['height']));
                 $nodePiece->addChild('Depth', round($params['length']));
             } else {
                 $nodePiece->addChild('Depth', round($params['length']));
                 $nodePiece->addChild('Width', round($params['width']));
                 $nodePiece->addChild('Height', round($params['height']));
             }
         }
         $content = array();
         foreach ($package['items'] as $item) {
             $content[] = $item['name'];
         }
         $nodePiece->addChild('PieceContents', substr(implode(',', $content), 0, 34));
     }
     if (!$originRegion) {
         $nodeShipmentDetails->addChild('Weight', round($rawRequest->getPackageWeight(), 1));
         $nodeShipmentDetails->addChild('WeightUnit', substr($this->_getWeightUnit(), 0, 1));
         $nodeShipmentDetails->addChild('GlobalProductCode', $rawRequest->getShippingMethod());
         $nodeShipmentDetails->addChild('LocalProductCode', $rawRequest->getShippingMethod());
         $nodeShipmentDetails->addChild('Date', Mage::getModel('core/date')->date(self::REQUEST_DATE_FORMAT));
         $nodeShipmentDetails->addChild('Contents', 'DHL Parcel');
         /*
          * The DoorTo Element defines the type of delivery service that applies to the shipment.
          * The valid values are DD (Door to Door), DA (Door to Airport) , AA and DC (Door to
          * Door non-compliant)
          */
         $nodeShipmentDetails->addChild('DoorTo', 'DD');
         $nodeShipmentDetails->addChild('DimensionUnit', substr($this->_getDimensionUnit(), 0, 1));
         if ($package['params']['container'] == self::DHL_CONTENT_TYPE_NON_DOC) {
             $packageType = 'CP';
         }
         $nodeShipmentDetails->addChild('PackageType', $packageType);
         if ($this->getConfigData('content_type') == self::DHL_CONTENT_TYPE_NON_DOC) {
             $nodeShipmentDetails->addChild('IsDutiable', 'Y');
         }
         $nodeShipmentDetails->addChild('CurrencyCode', Mage::app()->getWebsite($this->_request->getWebsiteId())->getBaseCurrencyCode());
     } else {
         if ($package['params']['container'] == self::DHL_CONTENT_TYPE_NON_DOC) {
             $packageType = 'CP';
         }
         $nodeShipmentDetails->addChild('PackageType', $packageType);
         $nodeShipmentDetails->addChild('Weight', $rawRequest->getPackageWeight());
         $nodeShipmentDetails->addChild('DimensionUnit', substr($this->_getDimensionUnit(), 0, 1));
         $nodeShipmentDetails->addChild('WeightUnit', substr($this->_getWeightUnit(), 0, 1));
         $nodeShipmentDetails->addChild('GlobalProductCode', $rawRequest->getShippingMethod());
         $nodeShipmentDetails->addChild('LocalProductCode', $rawRequest->getShippingMethod());
         /*
          * The DoorTo Element defines the type of delivery service that applies to the shipment.
          * The valid values are DD (Door to Door), DA (Door to Airport) , AA and DC (Door to
          * Door non-compliant)
          */
         $nodeShipmentDetails->addChild('DoorTo', 'DD');
         $nodeShipmentDetails->addChild('Date', Mage::getModel('core/date')->date(self::REQUEST_DATE_FORMAT));
         $nodeShipmentDetails->addChild('Contents', 'DHL Parcel');
     }
 }
开发者ID:okite11,项目名称:frames21,代码行数:93,代码来源:International.php


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