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


PHP Mage_Shipping_Model_Rate_Request::getPackageCurrency方法代码示例

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


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

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

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

 /**
  * 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;
     }
     $result = Mage::getModel('shipping/rate_result');
     $packageValue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
     $allow = $request->getFreeShipping() || $packageValue >= $this->getConfigData('cutoff_cost');
     if ($allow) {
         $method = Mage::getModel('shipping/rate_result_method');
         $method->setCarrier('freeshipping');
         $method->setCarrierTitle($this->getConfigData('title'));
         $method->setMethod('freeshipping');
         $method->setMethodTitle($this->getConfigData('name'));
         $method->setPrice('0.00');
         $method->setCost('0.00');
         $result->append($method);
     }
     return $result;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:26,代码来源:Freeshipping.php

示例4: 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;
     }
     $allow = $request->getmultiflat();
     $result = Mage::getModel('shipping/rate_result');
     $packageValue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
     for ($i = 0; $i <= 10; $i++) {
         if ($this->getConfigData('type' . $i) == 'O') {
             // per order
             $shippingPrice = $this->getConfigData('price' . $i);
         } elseif ($this->getConfigData('type' . $i) == 'I') {
             // per item
             $shippingPrice = $request->getPackageQty() * $this->getConfigData('price' . $i) - $this->getFreeBoxes() * $this->getConfigData('price' . $i);
         } else {
             $shippingPrice = $this->getConfigData('price' . $i);
         }
         $shippingName = $this->getConfigData('name' . $i);
         if ($shippingName != "" && ($packageValue >= $this->getConfigData('min_shipping' . $i) && $packageValue <= $this->getConfigData('max_shipping' . $i)) or $shippingName != "" && $this->getConfigData('max_shipping' . $i) == "") {
             $method = Mage::getModel('shipping/rate_result_method');
             $method->setCarrier('msmultiflat');
             $method->setCarrierTitle($this->getConfigData('title'));
             $method->setMethod($this->getConfigData('name' . $i));
             $method->setMethodTitle($this->getConfigData('name' . $i));
             $method->setMethodDetails($this->getConfigData('details' . $i));
             $method->setMethodDescription($this->getConfigData('details' . $i));
             $method->setPrice($shippingPrice);
             $method->setCost($shippingPrice);
             $result->append($method);
         } else {
             if ($shippingName == "") {
             }
         }
     }
     return $result;
 }
开发者ID:bevello,项目名称:bevello,代码行数:43,代码来源:Multiflat.php

示例5: _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)
 {
     if (!$this->getConfigFlag('active')) {
         // Disabled
         Mage::log('pedroteixeira_correios: Disabled');
         return false;
     }
     $origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
     $destCountry = $request->getDestCountryId();
     if ($origCountry != 'BR' || $destCountry != 'BR') {
         // Out of delivery area
         Mage::log('pedroteixeira_correios: Out of delivery area');
         return false;
     }
     $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));
     if (!preg_match('/^([0-9]{8})$/', $this->_fromZip)) {
         Mage::log('pedroteixeira_correios: From ZIP Code Error');
         return false;
     }
     $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:NelisRodrigues,项目名称:correios,代码行数:35,代码来源:CorreiosMethod.php

示例6: _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

示例7: _inicialCheck

 /**
  * Make initial checks and iniciate module variables
  *
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return boolean
  */
 protected function _inicialCheck(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$this->getConfigFlag('active')) {
         //Disabled
         Mage::log('O2TI_Sisfrete: Disabled');
         return false;
     }
     $origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
     $destCountry = $request->getDestCountryId();
     if ($origCountry != "BR" || $destCountry != "BR") {
         //Out of delivery area
         Mage::log('O2TI_Sisfrete: Out of delivery area');
         return false;
     }
     // ZIP Code
     $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));
     if (!preg_match("/^([0-9]{8})\$/", $this->_fromZip)) {
         //From zip code error
         Mage::log('O2TI_Sisfrete: From ZIP Code Error');
         return false;
     }
     // Result model
     $this->_result = Mage::getModel('shipping/rate_result');
     // Value
     $this->_packageValue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
     // Weight
     $this->_packageWeight = number_format($request->getPackageWeight(), 2, '.', '');
     // Free method weight
     $this->_freeMethodWeight = number_format($request->getFreeMethodWeight(), 2, '.', '');
 }
开发者ID:Aerotexextintores,项目名称:novosite,代码行数:40,代码来源:SisfreteMethod.php

示例8: collectRates

 /**
  * Collect Rates
  *
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return Mage_Shipping_Model_Rate_Result
  */
 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$this->getConfigFlag('active')) {
         //Disabled
         return false;
     }
     $origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
     $destCountry = $request->getDestCountryId();
     if ($origCountry != "BR" || $destCountry != "BR") {
         //Out of delivery area
         return false;
     }
     // Generate Volume Weight
     if ($this->_generateVolumeWeight() === false) {
         // Dimension error
         $this->_throwError('dimensionerror', 'Dimension error', __LINE__);
         return $this->_result;
     }
     $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());
     $minorderval = $this->getConfigData('min_order_value');
     $maxorderval = $this->getConfigData('max_order_value');
     if ($packagevalue <= $minorderval || $packagevalue >= $maxorderval) {
         //Value limits
         $error->setErrorMessage($this->getConfigData('valueerror'));
         $result->append($error);
         return $result;
     }
     $frompcode = Mage::getStoreConfig('shipping/origin/postcode', $this->getStore());
     $topcode = $request->getDestPostcode();
     //Fix Zip Code
     $frompcode = str_replace('-', '', trim($frompcode));
     $topcode = str_replace('-', '', trim($topcode));
     if (!preg_match("/^([0-9]{8})\$/", $topcode)) {
         //Invalid Zip Code
         $error->setErrorMessage($this->getConfigData('zipcodeerror'));
         $result->append($error);
         Mage::helper('customer')->__('Invalid ZIP CODE');
         return $result;
     }
     $sweight = $request->getPackageWeight();
     $valor = number_format($packagevalue, 2, ',', '');
     $peso = number_format($sweight, 2, ',', '');
     try {
         $retorno = $this->CalcFreteJamef($this->getConfigData('cnpj'), $topcode, $valor, $peso, $this->_volumeWeight, $this->getConfigData('filial_jamef'), $this->getConfigData('uf_jamef'));
     } catch (Exception $e) {
         $error->setErrorMessage($this->getConfigData('urlerror'));
         Mage::log($result->append($error));
         return $result;
     }
     $err_msg = "OK";
     if (trim($err_msg) == "OK") {
         $shippingPrice = str_replace(',', '.', $retorno->frete->valor);
     } else {
         //Invalid Zip Code
         $error->setErrorMessage($this->getConfigData('zipcodeerror'));
         echo $result->append($error);
         return $result;
     }
     if ($shippingPrice <= 0) {
         //Invalid Zip Code
         $error->setErrorMessage($this->getConfigData('zipcodeerror'));
         $result->append($error);
         Mage::helper('customer')->__('Invalid ZIP CODE');
         return $result;
     }
     $method = Mage::getModel('shipping/rate_result_method');
     $method->setCarrier($this->_code);
     $method->setCarrierTitle($this->getConfigData('name'));
     $method->setMethod('jamef');
     //	if ($this->getConfigFlag('prazo_entrega')){
     //		$method->setMethodTitle(sprintf($this->getConfigData('msgprazo'), '', $retorno->PRAZO ));
     //	}else{
     //		$method->setMethodTitle('Jamef');
     //	}
     $method->setPrice($shippingPrice + $shippingPrice * ($this->getConfigData('handling_fee') / 100));
     $method->setCost($shippingPrice);
     $result->append($method);
     $this->_result = $result;
     //		$this->_updateFreeMethodQuote($request);
     return $this->_result;
 }
开发者ID:nestormagento,项目名称:jamef-shipping,代码行数:91,代码来源:EnvioJamef.php

示例9: 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)
 {
     // skip if not enabled
     if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) {
         return false;
     }
     $result = Mage::getModel('shipping/rate_result');
     $packageValue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
     $temp = array();
     //get sheepla module config
     $sConfig = Mage::getStoreConfig('sheepla');
     //if user is using dynamic pricing
     if ($sConfig['advanced']['use_dynamic_pricing']) {
         //support admin and user checkout
         if (Mage::getSingleton('admin/session')->isLoggedIn()) {
             //admin
             $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
         } else {
             //user
             $quote = Mage::getSingleton('checkout/session')->getQuote();
         }
         $items = $quote->getAllVisibleItems();
         $address = $quote->getShippingAddress();
         try {
             $this->initSheeplaObjects();
             $dpRates = $this->sp->getClient()->getDynamicPricing($address, $items);
             $availableDynamicTemplateIds = array();
             foreach ($dpRates as $rate) {
                 $availableDynamicTemplateIds[] = $rate['shipmentTemplateId'];
             }
         } catch (Exception $e) {
             $dpRates = false;
             Mage::Log('[Sheepla][' . date('Y-m-d H:i:s') . ']' . $e->getMessage());
         }
     } else {
         $dpRates = false;
     }
     for ($i = 1; $i <= 10; $i++) {
         if ($this->getMethodConfig('allowspecific', $i)) {
             $availableCountries = explode(',', $this->getMethodConfig('specificcountry', $i));
             if (!($availableCountries && in_array($request->getDestCountryId(), $availableCountries))) {
                 continue;
             }
         }
         $shippingName = $this->getMethodConfig('name', $i);
         $shippingPrice = $this->getMethodConfig('price', $i);
         if (!empty($shippingName)) {
             //if dynamic pricing enabled and method is not at dpRates table, skip this method
             if (is_array($dpRates)) {
                 $shippingTemplateId = $this->getMethodConfig('template_id', $i);
                 if ($shippingTemplateId != '0' && !in_array($shippingTemplateId, $availableDynamicTemplateIds)) {
                     continue;
                 }
             }
             $method = Mage::getModel('shipping/rate_result_method');
             $method->setCarrier('sheepla');
             $method->setMethod('method_' . $i);
             $method->setMethodTitle($this->getMethodConfig('name', $i));
             $method->setMethodDetails($this->getMethodConfig('desc', $i));
             $method->setMethodDescription($this->getMethodConfig('desc', $i));
             $method->setPrice(preg_replace('/,/', '.', $shippingPrice));
             $method->setCost($this->getMethodConfig('cost', $i));
             if (isset($sConfig['advanced']['custom_label']) && !empty($sConfig['advanced']['custom_label'])) {
                 $method->setCarrierTitle($sConfig['advanced']['custom_label']);
             } else {
                 $method->setCarrierTitle(Mage::helper('sheepla/data')->__('Robust delivery by Sheepla!'));
             }
             //dynamic price calculate
             if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
                 $method->setPrice('0.00');
             } elseif (is_array($dpRates)) {
                 foreach ($sConfig as $k => $v) {
                     if ($method->getMethod() == $k) {
                         foreach ($dpRates as $rule) {
                             if ($rule['shipmentTemplateId'] == $v['template_id']) {
                                 $method->setPrice($rule['price']);
                             }
                         }
                     }
                 }
             }
             $temp[$this->getMethodConfig('sort_order', $i)] = $method;
         }
     }
     foreach ($temp as $m) {
         $result->append($m);
     }
     return $result;
 }
开发者ID:xiaoguizhidao,项目名称:ortodon,代码行数:95,代码来源:Sheepla.php

示例10: _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)
 {
     if (!$this->getConfigFlag('active')) {
         // Disabled
         Mage::log('pedroteixeira_correios: Disabled');
         return false;
     }
     $origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
     $destCountry = $request->getDestCountryId();
     if ($origCountry != 'BR' || $destCountry != 'BR') {
         // Out of delivery area
         Mage::log('pedroteixeira_correios: Out of delivery area');
         return false;
     }
     $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));
     if (!preg_match('/^([0-9]{8})$/', $this->_fromZip)) {
         Mage::log('pedroteixeira_correios: From ZIP Code Error');
         return false;
     }
     $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, '.', '');
     if ($this->_packageWeight <= 0) {
         $this->_packageWeight = 0;
         foreach ($request->getAllItems() as $item) {
             $prod = Mage::getModel('catalog/product');
             $prod->load($item->getProduct()->getId());
             if ($prod->getTypeID() == 'configurable') {
                 $lastQty = $item->getQty();
                 $qtd = 0;
                 continue;
             } else {
                 if ($lastQty > 0) {
                     $qtd = $lastQty;
                     $lastQty = 0;
                 }
             }
             $this->_packageWeight = $this->_packageWeight + $prod->getWeight() * $qtd;
         }
     }
 }
开发者ID:aandrade1234,项目名称:correios,代码行数:53,代码来源:CorreiosMethod.php


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