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


PHP Mage_Shipping_Model_Rate_Request::setConditionName方法代码示例

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


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

示例1: collectRates

 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$this->getConfigFlag('active')) {
         return false;
     }
     if (!$request->getConditionName()) {
         $request->setConditionName($this->getConfigData('condition_name') ? $this->getConfigData('condition_name') : $this->_default_condition_name);
     }
     $result = Mage::getModel('shipping/rate_result');
     $rates = $this->getRate($request);
     if (is_array($rates)) {
         foreach ($rates as $rate) {
             if (!empty($rate) && $rate['price'] >= 0) {
                 /** @var Mage_Shipping_Model_Rate_Result_Method $method */
                 $method = Mage::getModel('shipping/rate_result_method');
                 $method->setCarrier('eparcel');
                 $method->setCarrierTitle($this->getConfigData('title'));
                 if ($this->_getChargeCode($rate)) {
                     $_method = strtolower(str_replace(' ', '_', $this->_getChargeCode($rate)));
                 } else {
                     $_method = strtolower(str_replace(' ', '_', $rate['delivery_type']));
                 }
                 $method->setMethod($_method);
                 if ($this->getConfigData('carriers/eparcel/name')) {
                     $method->setMethodTitle($this->getConfigData('carriers/eparcel/name'));
                 } else {
                     $method->setMethodTitle($rate['delivery_type']);
                 }
                 $method->setMethodChargeCodeIndividual($rate['charge_code_individual']);
                 $method->setMethodChargeCodeBusiness($rate['charge_code_business']);
                 $shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
                 $method->setPrice($shippingPrice);
                 $method->setCost($rate['cost']);
                 $method->setDeliveryType($rate['delivery_type']);
                 $result->append($method);
             }
         }
     } else {
         if (!empty($rates) && $rates['price'] >= 0) {
             $method = Mage::getModel('shipping/rate_result_method');
             $method->setCarrier('eparcel');
             $method->setCarrierTitle($this->getConfigData('title'));
             $method->setMethod('bestway');
             $method->setMethodTitle($this->getConfigData('name'));
             $method->setMethodChargeCodeIndividual($rates['charge_code_individual']);
             $method->setMethodChargeCodeBusiness($rates['charge_code_business']);
             $shippingPrice = $this->getFinalPriceWithHandlingFee($rates['price']);
             $method->setPrice($shippingPrice);
             $method->setCost($rates['cost']);
             $method->setDeliveryType($rates['delivery_type']);
             $result->append($method);
         }
     }
     return $result;
 }
开发者ID:rob3000,项目名称:fontis_australia,代码行数:55,代码来源:Eparcel.php

示例2: collectRates

 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$this->getConfigFlag('active')) {
         return false;
     }
     if (!$request->getConditionName()) {
         $request->setConditionName($this->getConfigData('condition_name') ? $this->getConfigData('condition_name') : $this->_default_condition_name);
     }
     $result = Mage::getModel('shipping/rate_result');
     $rates = $this->getRate($request);
     if (is_array($rates)) {
         foreach ($rates as $rate) {
             if (!empty($rate) && $rate['price'] >= 0) {
                 $method = Mage::getModel('shipping/rate_result_method');
                 $method->setCarrier('eparcel');
                 $method->setCarrierTitle($this->getConfigData('title'));
                 $method->setMethod($rate['delivery_type']);
                 $method->setMethodTitle($rate['delivery_type']);
                 $shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
                 $method->setPrice($shippingPrice);
                 $method->setCost($rate['cost']);
                 $method->setDeliveryType($rate['delivery_type']);
                 $result->append($method);
             }
         }
     } else {
         if (!empty($rates) && $rates['price'] >= 0) {
             $method = Mage::getModel('shipping/rate_result_method');
             $method->setCarrier('eparcel');
             $method->setCarrierTitle($this->getConfigData('title'));
             $method->setMethod('bestway');
             $method->setMethodTitle($this->getConfigData('name'));
             $shippingPrice = $this->getFinalPriceWithHandlingFee($rates['price']);
             $method->setPrice($shippingPrice);
             $method->setCost($rates['cost']);
             $method->setDeliveryType($rates['delivery_type']);
             $result->append($method);
         }
     }
     return $result;
 }
开发者ID:cnglobal-sl,项目名称:caterez,代码行数:41,代码来源:Eparcel.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;
     }
     if (!$request->getConditionName()) {
         $request->setConditionName($this->getConfigData('condition_name'));
     }
     $result = Mage::getModel('shipping/rate_result');
     $rate = $this->getRate($request);
     if (!empty($rate) && $rate['price'] >= 0) {
         $method = Mage::getModel('shipping/rate_result_method');
         $method->setCarrier('tablerate');
         $method->setCarrierTitle($this->getConfigData('title'));
         $method->setMethod('bestway');
         $method->setMethodTitle($this->getConfigData('name'));
         $shippingPrice = $rate['price'] + $this->getConfigData('handling_fee');
         $method->setPrice($shippingPrice);
         $method->setCost($rate['cost']);
         $result->append($method);
     }
     return $result;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:29,代码来源:Tablerate.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;
     }
     // 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());
             }
         }
     }
     // 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);
     }
     // Package weight and qty free shipping
     $oldWeight = $request->getPackageWeight();
     $oldQty = $request->getPackageQty();
     $request->setPackageWeight($request->getFreeMethodWeight());
     $request->setPackageQty($oldQty - $freeQty);
     $result = Mage::getModel('Mage_Shipping_Model_Rate_Result');
     $rate = $this->getRate($request);
     $request->setPackageWeight($oldWeight);
     $request->setPackageQty($oldQty);
     if (!empty($rate) && $rate['price'] >= 0) {
         $method = Mage::getModel('Mage_Shipping_Model_Rate_Result_Method');
         $method->setCarrier('tablerate');
         $method->setCarrierTitle($this->getConfigData('title'));
         $method->setMethod('bestway');
         $method->setMethodTitle($this->getConfigData('name'));
         if ($request->getFreeShipping() === true || $request->getPackageQty() == $freeQty) {
             $shippingPrice = 0;
         } else {
             $shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
         }
         $method->setPrice($shippingPrice);
         $method->setCost($rate['cost']);
         $result->append($method);
     }
     return $result;
 }
开发者ID:relue,项目名称:magento2,代码行数:75,代码来源:Tablerate.php

示例5: collectRates

 /**
  * Collect and get 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')) {
         return false;
     }
     // exclude Virtual products price from Package value if pre-configured
     if (!$this->getConfigFlag('include_virtual_price') && $request->getAllItems()) {
         foreach ($request->getAllItems() as $item) {
             if ($item->getParentItem()) {
                 continue;
             }
             if ($item->getHasChildren() && $item->isShipSeparately()) {
                 foreach ($item->getChildren() as $child) {
                     if ($child->getProduct()->isVirtual()) {
                         $request->setPackageValue($request->getPackageValue() - $child->getBaseRowTotal());
                     }
                 }
             } elseif ($item->getProduct()->isVirtual()) {
                 $request->setPackageValue($request->getPackageValue() - $item->getBaseRowTotal());
             }
         }
     }
     // Free shipping by qty
     $freeQty = 0;
     if ($request->getAllItems()) {
         $freePackageValue = 0;
         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()) {
                         $freeShipping = is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0;
                         $freeQty += $item->getQty() * ($child->getQty() - $freeShipping);
                     }
                 }
             } elseif ($item->getFreeShipping()) {
                 $freeShipping = is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0;
                 $freeQty += $item->getQty() - $freeShipping;
                 $freePackageValue += $item->getBaseRowTotal();
             }
         }
         $oldValue = $request->getPackageValue();
         $request->setPackageValue($oldValue - $freePackageValue);
     }
     if ($freePackageValue) {
         $request->setPackageValue($request->getPackageValue() - $freePackageValue);
     }
     if (!$request->getConditionName()) {
         $conditionName = $this->getConfigData('condition_name');
         $request->setConditionName($conditionName ? $conditionName : $this->_default_condition_name);
     }
     // Package weight and qty free shipping
     $oldWeight = $request->getPackageWeight();
     $oldQty = $request->getPackageQty();
     $request->setPackageWeight($request->getFreeMethodWeight());
     $request->setPackageQty($oldQty - $freeQty);
     $result = $this->_getModel('shipping/rate_result');
     $rate = $this->getRate($request);
     $request->setPackageWeight($oldWeight);
     $request->setPackageQty($oldQty);
     if (!empty($rate) && $rate['price'] >= 0) {
         $method = $this->_getModel('shipping/rate_result_method');
         $method->setCarrier('tablerate');
         $method->setCarrierTitle($this->getConfigData('title'));
         $method->setMethod('bestway');
         $method->setMethodTitle($this->getConfigData('name'));
         if ($request->getFreeShipping() === true || $request->getPackageQty() == $freeQty) {
             $shippingPrice = 0;
         } else {
             $shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
         }
         $method->setPrice($shippingPrice);
         $method->setCost($rate['cost']);
         $result->append($method);
     } elseif (empty($rate) && $request->getFreeShipping() === true) {
         /**
          * was applied promotion rule for whole cart
          * other shipping methods could be switched off at all
          * we must show table rate method with 0$ price, if grand_total more, than min table condition_value
          * free setPackageWeight() has already was taken into account
          */
         $request->setPackageValue($freePackageValue);
         $request->setPackageQty($freeQty);
         $rate = $this->getRate($request);
         if (!empty($rate) && $rate['price'] >= 0) {
             $method = $this->_getModel('shipping/rate_result_method');
             $method->setCarrier('tablerate');
             $method->setCarrierTitle($this->getConfigData('title'));
             $method->setMethod('bestway');
             $method->setMethodTitle($this->getConfigData('name'));
             $method->setPrice(0);
             $method->setCost(0);
//.........这里部分代码省略.........
开发者ID:buttasg,项目名称:cowgirlk,代码行数:101,代码来源:Tablerate.php

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

示例7: collectRates

 /**
  * Collect shipping method price and set all data selected in config.
  *
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return bool|false|Mage_Core_Model_Abstract
  */
 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) {
         return false;
     }
     $method = Mage::getModel('shipping/rate_result_method');
     $result = Mage::getModel('shipping/rate_result');
     if (!$this->getConfigData('ratetype')) {
         $price = $this->getConfigData('flatrateprice');
         if ($request->getFreeShipping() === true) {
             $price = 0;
         }
     } else {
         $freeQty = 0;
         if ($request->getAllItems()) {
             $freePackageValue = 0;
             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()) {
                             $freeShipping = is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0;
                             $freeQty += $item->getQty() * ($child->getQty() - $freeShipping);
                         }
                     }
                 } elseif ($item->getFreeShipping()) {
                     $freeShipping = is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0;
                     $freeQty += $item->getQty() - $freeShipping;
                     $freePackageValue += $item->getBaseRowTotal();
                 }
             }
             $oldValue = $request->getPackageValue();
             $request->setPackageValue($oldValue - $freePackageValue);
         }
         if ($freePackageValue) {
             $request->setPackageValue($request->getPackageValue() - $freePackageValue);
         }
         $conditionName = $this->getConfigData('condition_name');
         $request->setConditionName($conditionName ? $conditionName : $this->_default_condition_name);
         $oldWeight = $request->getPackageWeight();
         $oldQty = $request->getPackageQty();
         $request->setPackageWeight($request->getFreeMethodWeight());
         $request->setPackageQty($oldQty - $freeQty);
         $rate = $this->getRate($request);
         $request->setPackageWeight($oldWeight);
         $request->setPackageQty($oldQty);
         if (!empty($rate) && $rate['price'] >= 0) {
             if ($request->getFreeShipping() === true || $request->getPackageQty() == $freeQty) {
                 $price = 0;
             } else {
                 $price = $rate['price'];
             }
         } elseif (empty($rate) && $request->getFreeShipping() === true) {
             $request->setPackageValue($freePackageValue);
             $request->setPackageQty($freeQty);
             $rate = $this->getRate($request);
             if (!empty($rate) && $rate['price'] >= 0) {
                 $price = 0;
             }
         } else {
             $error = Mage::getModel('shipping/rate_result_error');
             $error->setCarrier($this->_code);
             $error->setCarrierTitle($this->getConfigData('title'));
             $error->setErrorMessage(Mage::helper('dpd')->__('This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.'));
             $result->append($error);
             return $result;
         }
     }
     $method->setCarrier($this->_code);
     $method->setMethod($this->_code);
     $method->setMethodTitle($this->getConfigData('name'));
     $method->setCarrierTitle($this->getConfigData('carrier'));
     $method->setPrice($price);
     $method->setCost($price);
     $result->append($method);
     return $result;
 }
开发者ID:vovayatsyuk,项目名称:magento-DPD_Shipping,代码行数:85,代码来源:Dpdclassic.php

示例8: collectRates

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

示例9: collectRates

 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$this->getConfigFlag('active')) {
         return false;
     }
     // exclude Virtual products price from Package value if pre-configured
     if (!$this->getConfigFlag('include_virtual_price') && $request->getAllItems()) {
         $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
         foreach ($request->getAllItems() as $item) {
             if ($item->getParentItem()) {
                 continue;
             }
             /*
              * Changes for the individual product shipping in Fixed Priced bundle
              */
             $finalPrice = 0;
             if ($item->getHasChildren() && $item->isShipSeparately()) {
                 foreach ($item->getChildren() as $child) {
                     if ($item->getProductType() == 'bundle' && $item->getProduct()->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_FIXED) {
                         $child->getProduct()->setCustomerGroupId($groupId);
                         $price = $child->getProduct()->getPriceModel()->getFinalPrice($child->getQty(), $child->getProduct()) * $item->getQty();
                         if (!$child->getProduct()->isVirtual()) {
                             $finalPrice = $finalPrice + $price;
                         }
                     } else {
                         if ($child->getProduct()->isVirtual()) {
                             $request->setPackageValue($request->getPackageValue() - $child->getBaseRowTotal());
                         }
                     }
                 }
                 if ($item->getProductType() == 'bundle' && $item->getProduct()->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_FIXED) {
                     $request->setPackageValue($request->getPackageValue() - $item->getBaseRowTotal());
                     $request->setPackagePhysicalValue($request->getPackagePhysicalValue() - $item->getBaseRowTotal());
                     $request->setPackageValue($request->getPackageValue() + $finalPrice);
                     $request->setPackagePhysicalValue($request->getPackagePhysicalValue() + $finalPrice);
                 }
             } elseif ($item->getProduct()->isVirtual()) {
                 $request->setPackageValue($request->getPackageValue() - $item->getBaseRowTotal());
             }
         }
     }
     // Free shipping by qty
     $freeQty = 0;
     $freePackageValue = 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);
                 $freePackageValue += $item->getRowTotal();
             }
         }
     }
     if ($freePackageValue) {
         $request->setPackageValue($request->getPackageValue() - $freePackageValue);
     }
     if (!$request->getConditionName()) {
         $request->setConditionName($this->getConfigData('condition_name') ? $this->getConfigData('condition_name') : $this->_default_condition_name);
     }
     // Package weight and qty free shipping
     $oldWeight = $request->getPackageWeight();
     $oldQty = $request->getPackageQty();
     $request->setPackageWeight($request->getFreeMethodWeight());
     $request->setPackageQty($oldQty - $freeQty);
     $result = Mage::getModel('shipping/rate_result');
     $rate = $this->getRate($request);
     $request->setPackageWeight($oldWeight);
     $request->setPackageQty($oldQty);
     if (!empty($rate) && $rate['price'] >= 0) {
         $method = Mage::getModel('shipping/rate_result_method');
         $method->setCarrier('tablerate');
         $method->setCarrierTitle($this->getConfigData('title'));
         $method->setMethod('bestway');
         $method->setMethodTitle($this->getConfigData('name'));
         if ($request->getFreeShipping() === true || $request->getPackageQty() == $freeQty) {
             $shippingPrice = 0;
         } elseif (isset($rate['calculation_type']) && $rate['calculation_type'] == ICC_TableRateMixed_Model_Resource_Carrier_Tablerate::CALCULATION_TYPE_PERCENTAGE) {
             $shippingPrice = $this->_getPercentPriceOfCartSubtotal($rate['price'], $request);
         } else {
             $shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
         }
         $method->setPrice($shippingPrice);
         $method->setCost($rate['cost']);
         $result->append($method);
     } elseif (empty($rate) && $request->getFreeShipping() === true) {
         /**
          * was applied promotion rule for whole cart
          * other shipping methods could be switched off at all
          * we must show table rate method with 0$ price, if grand_total more, than min table condition_value
          * free setPackageWeight() has already was taken into account
          */
         $request->setPackageValue($freePackageValue);
//.........这里部分代码省略.........
开发者ID:ankita-parashar,项目名称:magento,代码行数:101,代码来源:ICC_TableRateMixed_Model_Carrier_Tablerate.php

示例10: collectRates

 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     try {
         $result = Mage::getModel('shipping/rate_result');
         if (!$this->getConfigData('active')) {
             return $result;
         }
         $shipping_free_cart_price = null;
         if ($this->getConfigData('free_active')) {
             $shipping_free_cart_price = $this->getConfigData('free_price');
         }
         $request->setConditionName($this->getConfigData('condition_name') ? $this->getConfigData('condition_name') : $this->_default_condition_name);
         if ($this->getConfigData('package_weight')) {
             $request->_data['package_weight'] = $request->_data['package_weight'] + $this->getConfigData('package_weight') / 1000;
         }
         $quote = Mage::getModel('sales/quote');
         if (isset($data['cart'])) {
             foreach ($data['cart'] as $id => $itemqty) {
                 $item = Mage::getModel('sales/quote_item')->load($id);
                 if (!$quote->getId()) {
                     $quote->load($item->getQuoteId());
                 }
                 $item->setQuote($quote);
                 $product = $item->getProduct();
                 if ($product->getTypeId() != 'configurable') {
                     $process['products'][] = array("product" => $product, "qtycart" => $itemqty);
                 }
             }
         } else {
             $cart = Mage::getModel('checkout/cart')->getQuote();
             foreach ($cart->getAllItems() as $item) {
                 $product = Mage::getModel('catalog/product')->load($item->getProduct()->getId());
                 if ($product->getTypeId() != 'configurable') {
                     $process['products'][] = array("product" => $product, "qtycart" => $item->getQty());
                 }
             }
         }
         if (isset($process['products'])) {
             foreach ($process['products'] as $product) {
                 $rates = $this->getRate($request, $product['product'], $product['qtycart']);
                 //$productShippingPrice = $rate['price'];
                 //$productn = $product['product'];
                 /*if ($productShippingPrice > $maxProductShippingPrice) {
                 			$maxProductShippingPrice = $productShippingPrice;
                 			if ($product['qty']>1){
                 				$maxProductShippingPrice *= $coeff;
                 			}
                 		}*/
             }
         }
         $cartTmp = $request->_data['package_value_with_discount'];
         $weghtTmp = $request->_data['package_weight'];
         foreach ($rates as $rate) {
             if (!empty($rate) && $rate['price'] >= 0) {
                 /*---------------------------------------- Liste des points relais -----------------------------------------*/
                 // On met en place les paramètres de la requète
                 $params = array('Enseigne' => $this->getConfigData('enseigne'), 'Pays' => $request->_data['dest_country_id'], 'CP' => $request->_data['dest_postcode']);
                 //On crée le code de sécurité
                 $code = implode("", $params);
                 $code .= $this->getConfigData('cle');
                 //On le rajoute aux paramètres
                 $params["Security"] = strtoupper(md5($code));
                 // On se connecte
                 $client = new SoapClient("http://www.mondialrelay.fr/WebService/Web_Services.asmx?WSDL");
                 // Et on effectue la requète
                 $points_relais = $client->WSI2_RecherchePointRelais($params)->WSI2_RecherchePointRelaisResult;
                 $i = 0;
                 // On cr�e une m�thode de livraison par point relais
                 foreach ($points_relais as $point_relais) {
                     if (is_object($point_relais) && trim($point_relais->Num) != '') {
                         $i++;
                         $method = Mage::getModel('shipping/rate_result_method');
                         $method->setCarrier('pointsrelais');
                         $method->setCarrierTitle($this->getConfigData('title'));
                         $methodTitle = $point_relais->LgAdr1 . ' - ' . $point_relais->Ville . ' <a href="#" onclick="PointsRelais.showInfo(\'' . $point_relais->Num . '\'); return false;">Détails</a> - <span style="display:none;" id="pays">' . $request->_data['dest_country_id'] . '</span>';
                         $method->setMethod($point_relais->Num);
                         $method->setMethodTitle($methodTitle);
                         if ($shipping_free_cart_price != null && ($cartTmp > $shipping_free_cart_price && $weghtTmp > 0.101)) {
                             $price = $rate['price'] = 0;
                             $rate['cost'] = 0;
                             $method->setPrice($price);
                             $method->setCost($rate['cost']);
                         } else {
                             $price = $rate['price'];
                             $method->setPrice($this->getFinalPriceWithHandlingFee($price));
                             $method->setCost($rate['cost']);
                         }
                         $result->append($method);
                     }
                 }
                 if (!$i) {
                     $method = Mage::getModel('shipping/rate_result_method');
                     $method->setCarrier('pointsrelais');
                     $method->setCarrierTitle('');
                     $method->setMethod('000');
                     $method->setMethodTitle("Livraison");
                     $method->setPrice(0);
                     $method->setCost(0);
                     $result->append($method);
                 }
//.........这里部分代码省略.........
开发者ID:gabi77,项目名称:Gabi77_Mondialrelay,代码行数:101,代码来源:Pointsrelais.php


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