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


PHP Mage_Shipping_Model_Rate_Request::getPackageQty方法代码示例

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


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

示例1: collectRates

 /**
  * Enter description here...
  *
  * @param Mage_Shipping_Model_Rate_Request $data
  * @return Mage_Shipping_Model_Rate_Result
  */
 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$this->getConfigFlag('active')) {
         return false;
     }
     $freeBoxes = 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()) {
                         $freeBoxes += $item->getQty() * $child->getQty();
                     }
                 }
             } elseif ($item->getFreeShipping()) {
                 $freeBoxes += $item->getQty();
             }
         }
     }
     $this->setFreeBoxes($freeBoxes);
     $result = Mage::getModel('shipping/rate_result');
     if ($this->getConfigData('type') == 'O') {
         // per order
         $shippingPrice = $this->getConfigData('price');
     } elseif ($this->getConfigData('type') == 'I') {
         // per item
         $shippingPrice = $request->getPackageQty() * $this->getConfigData('price') - $this->getFreeBoxes() * $this->getConfigData('price');
     } else {
         $shippingPrice = false;
     }
     $shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
     if ($shippingPrice !== false) {
         $method = Mage::getModel('shipping/rate_result_method');
         $method->setCarrier('zabstorepickup');
         $method->setCarrierTitle($this->getConfigData('title'));
         $method->setMethod('storepickup');
         $method->setMethodTitle($this->getConfigData('name'));
         if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
             $shippingPrice = '0.00';
         }
         $method->setPrice($shippingPrice);
         $method->setCost($shippingPrice);
         $address = $this->getAddress();
         $additional = false;
         if ($address) {
             /**@var $address Mage_Customer_Model_Address**/
             $address = $address->format('html');
             $additional = Mage::helper('zab_storepickup')->__("Pickup in:") . "<br/>" . "<address>{$address}</address><br/>";
         }
         if ($this->getConfigData('instruction')) {
             $additional .= $this->getConfigData('instruction');
         }
         $method->setAdditionalInfo($additional);
         $result->append($method);
     }
     return $result;
 }
开发者ID:becchius,项目名称:fiordivaniglia,代码行数:66,代码来源:Storepickup.php

示例2: collectRates

 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$this->getConfigFlag('active')) {
         return false;
     }
     $freeBoxes = 0;
     if ($request->getAllItems()) {
         foreach ($request->getAllItems() as $item) {
             if ($item->getFreeShipping() && !$item->getProduct()->isVirtual()) {
                 $freeBoxes += $item->getQty();
             }
         }
     }
     $this->setFreeBoxes($freeBoxes);
     $quoteId = Mage::getSingleton('core/session')->proposal_quote_id;
     if ($quoteId) {
         $price = Mage::app()->getHelper('qquoteadv')->getQquoteShipPriceById($quoteId);
         $result = Mage::getModel('shipping/rate_result');
         /* if ($this->getConfigData('type') == 'O') { // per order
                $shippingPrice = $price;
            } elseif ($this->getConfigData('type') == 'I') { // per item
                $shippingPrice = ($request->getPackageQty() * $price) - ($this->getFreeBoxes() * $price);
            } else {
                $shippingPrice = false;
            }*/
         $type = Mage::app()->getHelper('qquoteadv')->getShipTypeByQuote();
         if ($type == 'O') {
             // per order
             $shippingPrice = $price;
         } elseif ($type == 'I') {
             // per item
             $shippingPrice = $request->getPackageQty() * $price - $this->getFreeBoxes() * $price;
         } else {
             $shippingPrice = false;
         }
         $shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
         if ($shippingPrice !== false) {
             $method = Mage::getModel('shipping/rate_result_method');
             $method->setCarrier('qquoteshiprate');
             $method->setCarrierTitle($this->getConfigData('title'));
             $method->setMethod('qquoteshiprate');
             if ($type == 'I') {
                 $method->setMethodTitle('Price per Item');
             } else {
                 $method->setMethodTitle($this->getConfigData('name'));
             }
             if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
                 $shippingPrice = '0.00';
             }
             $method->setPrice($shippingPrice);
             $method->setCost($shippingPrice);
             $result->append($method);
         }
         return $result;
     }
     return false;
 }
开发者ID:cnglobal-sl,项目名称:caterez,代码行数:57,代码来源:Qquoteshiprate.php

示例3: collectRates

 /**
  * Collect and get rates
  *
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return Mage_Shipping_Model_Rate_Result|bool|null
  */
 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$this->getConfigFlag('active')) {
         return false;
     }
     $activeForCustomerGroup = Mage::helper('emjainteractive_shippingoption')->isShippingMethodAvailable();
     if (!$activeForCustomerGroup) {
         return false;
     }
     $freeBoxes = 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()) {
                         $freeBoxes += $item->getQty() * $child->getQty();
                     }
                 }
             } elseif ($item->getFreeShipping()) {
                 $freeBoxes += $item->getQty();
             }
         }
     }
     $this->setFreeBoxes($freeBoxes);
     $result = Mage::getModel('shipping/rate_result');
     if ($this->getConfigData('type') == 'O') {
         // per order
         $shippingPrice = $this->getConfigData('price');
     } elseif ($this->getConfigData('type') == 'I') {
         // per item
         $shippingPrice = $request->getPackageQty() * $this->getConfigData('price') - $this->getFreeBoxes() * $this->getConfigData('price');
     } else {
         $shippingPrice = false;
     }
     $shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
     if ($shippingPrice !== false) {
         $method = Mage::getModel('shipping/rate_result_method');
         $method->setCarrier('umosaco');
         $method->setCarrierTitle($this->getConfigData('title'));
         $method->setMethod('umosaco');
         $method->setMethodTitle($this->getConfigData('name'));
         if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
             $shippingPrice = '0.00';
         }
         $method->setPrice($shippingPrice);
         $method->setCost($shippingPrice);
         $result->append($method);
     }
     return $result;
 }
开发者ID:billadams,项目名称:forever-frame,代码行数:59,代码来源:Umosaco.php

示例4: collectRates

 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$this->getConfigFlag('active')) {
         return false;
     }
     $freeBoxes = 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()) {
                         $freeBoxes += $item->getQty() * $child->getQty();
                     }
                 }
             } elseif ($item->getFreeShipping()) {
                 $freeBoxes += $item->getQty();
             }
         }
     }
     $this->setFreeBoxes($freeBoxes);
     $result = Mage::getModel('shipping/rate_result');
     if ($this->getConfigData('type') == 'O') {
         // per order
         $shippingPrice = $this->getConfigData('price');
     } elseif ($this->getConfigData('type') == 'I') {
         // per item
         $shippingPrice = $request->getPackageQty() * $this->getConfigData('price') - $this->getFreeBoxes() * $this->getConfigData('price');
     } else {
         $shippingPrice = false;
     }
     if (Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_PERCENT == $this->getConfigData('shipper_type')) {
         $shippingPrice = $request->getData('base_subtotal_incl_tax') * $shippingPrice / 100;
     }
     $shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
     if ($shippingPrice !== false) {
         $method = Mage::getModel('shipping/rate_result_method');
         $method->setCarrier('flatrate');
         $method->setCarrierTitle($this->getConfigData('title'));
         $method->setMethod('flatrate');
         $method->setMethodTitle($this->getConfigData('name'));
         if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
             $shippingPrice = '0.00';
         }
         $method->setPrice($shippingPrice);
         $method->setCost($shippingPrice);
         $result->append($method);
     }
     return $result;
 }
开发者ID:GastonDeMarsico,项目名称:improvedshipping,代码行数:52,代码来源:Carrier.php

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

示例6: 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');
     if ($this->getConfigData('type') == 'O') {
         // per order
         $shippingPrice = $this->getConfigData('price');
     } elseif ($this->getConfigData('type') == 'I') {
         // per item
         $shippingPrice = $request->getPackageQty() * $this->getConfigData('price');
     } else {
         $shippingPrice = false;
     }
     $shippingPrice += $this->getConfigData('handling_fee');
     if ($shippingPrice) {
         $method = Mage::getModel('shipping/rate_result_method');
         $method->setCarrier('flatrate');
         $method->setCarrierTitle($this->getConfigData('title'));
         $method->setMethod('flatrate');
         $method->setMethodTitle($this->getConfigData('name'));
         $method->setPrice($shippingPrice);
         $method->setCost($shippingPrice);
         $result->append($method);
     }
     return $result;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:34,代码来源:Flatrate.php

示例7: 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;
     }
     $freeBoxes = 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()) {
                         $freeBoxes += $item->getQty() * $child->getQty();
                     }
                 }
             } elseif ($item->getFreeShipping()) {
                 $freeBoxes += $item->getQty();
             }
         }
     }
     $this->setFreeBoxes($freeBoxes);
     $result = Mage::getModel('shipping/rate_result');
     if ($this->getConfigData('type') == 'O') {
         // per order
         $shippingPrice = $this->getConfigData('price');
     } elseif ($this->getConfigData('type') == 'I') {
         // per item
         $shippingPrice = $request->getPackageQty() * $this->getConfigData('price') - $this->getFreeBoxes() * $this->getConfigData('price');
     } else {
         $shippingPrice = false;
     }
     $voucher_code = Mage::getSingleton('core/session')->getData('voucher_code');
     $voucher = $this->verify_voucher_code($voucher_code);
     if ($voucher['order_type'] == '3MM') {
         $shippingPrice = 18;
     }
     $shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
     if ($shippingPrice !== false) {
         $method = Mage::getModel('shipping/rate_result_method');
         $method->setCarrier('flatrate');
         $method->setCarrierTitle($this->getConfigData('title'));
         $method->setMethod('flatrate');
         $method->setMethodTitle($this->getConfigData('name'));
         if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
             $shippingPrice = '0.00';
         }
         $method->setPrice($shippingPrice);
         $method->setCost($shippingPrice);
         $result->append($method);
     }
     return $result;
 }
开发者ID:Rodrifer,项目名称:candyclub,代码行数:60,代码来源:Flatrate.php

示例8: collectRates

 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     if (!$this->getConfigFlag('active')) {
         return false;
     }
     $freeBoxes = 0;
     if ($request->getAllItems()) {
         foreach ($request->getAllItems() as $item) {
             if ($item->getFreeShipping() && !$item->getProduct()->isVirtual()) {
                 $freeBoxes += $item->getQty();
             }
         }
     }
     $this->setFreeBoxes($freeBoxes);
     $result = Mage::getModel('shipping/rate_result');
     if ($this->getConfigData('type') == 'O') {
         // per order
         $shippingPrice = $this->getConfigData('price');
     } elseif ($this->getConfigData('type') == 'I') {
         // per item
         $shippingPrice = $request->getPackageQty() * $this->getConfigData('price') - $this->getFreeBoxes() * $this->getConfigData('price');
     } else {
         $shippingPrice = false;
     }
     $shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
     if ($shippingPrice !== false) {
         $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'));
         if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
             $shippingPrice = '0.00';
         }
         $method->setPrice($shippingPrice);
         $method->setCost($shippingPrice);
         $result->append($method);
     }
     return $result;
 }
开发者ID:RapidCommerceBV,项目名称:MagentoStorePickup,代码行数:40,代码来源:Storeforpickup.php

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

示例10: checkRate

 /**
  * applies filters for rate on request
  *
  * @param array $rate
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return boolean
  */
 public function checkRate(array $rate, Mage_Shipping_Model_Rate_Request $request)
 {
     if (!Mage::getSingleton('checkout/session')->getQuoteId()) {
         return true;
     }
     if (!isset($rate['filter'])) {
         return true;
     }
     $filters = explode(';', $rate['filter']);
     $passed = true;
     foreach ($filters as $filter) {
         $filter = explode(':', $filter);
         $condition = $filter[0];
         $value = isset($filter[1]) && $filter[1] ? $filter[1] : false;
         if ($value === false) {
             continue;
         }
         switch ($condition) {
             case 'min_qty':
                 if ($request->getPackageQty() < $value) {
                     $passed = false;
                 }
                 break;
             case 'max_qty':
                 if ($request->getPackageQty() > $value) {
                     $passed = false;
                 }
                 break;
             case 'min_subtotal':
                 if ($request->getPackageValueWithDiscount() < $value) {
                     $passed = false;
                 }
                 break;
             case 'max_subtotal':
                 if ($request->getPackageValueWithDiscount() > $value) {
                     $passed = false;
                 }
                 break;
             case 'min_weight':
                 if ($request->getPackageWeight() < $value) {
                     $passed = false;
                 }
                 break;
             case 'max_weight':
                 if ($request->getPackageWeight() > $value) {
                     $passed = false;
                 }
                 break;
             case 'countries':
                 $dest = strtolower($request->getDestCountryId());
                 if ($value[0] == '!') {
                     $exclude = true;
                     $value[0] = ' ';
                     // will be removed with trim() ;-)
                 } else {
                     $exclude = false;
                 }
                 $allowed = explode(',', strtolower($value));
                 foreach ($allowed as $k => $v) {
                     $allowed[$k] = trim($v);
                 }
                 if ($exclude) {
                     if (in_array($dest, $allowed) && count($allowed)) {
                         $passed = false;
                     }
                 } else {
                     if (!in_array($dest, $allowed) && count($allowed)) {
                         $passed = false;
                     }
                 }
                 break;
         }
     }
     return $passed;
 }
开发者ID:commercekitchen,项目名称:dualeyewear-magento,代码行数:82,代码来源:Carrier.php

示例11: collectRates

 /**
  * Enter description here...
  *
  * @param FCM_Shipping_Model_Rate_Request $data
  * @return FCM_Shipping_Model_Rate_Result
  */
 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     /* It will check whether Express shipping method is enable or not
     		  if not it will return to calling function without executing further
     		*/
     if (!$this->getConfigFlag('active')) {
         return false;
     }
     $freeBoxes = 0;
     if ($request->getAllItems()) {
         foreach ($request->getAllItems() as $item) {
             // Below line will check whether the product in question is virtual one or not
             if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
                 continue;
             }
             // Below line will be executed whether item in cart are shipped seperatly or not
             if ($item->getHasChildren() && $item->isShipSeparately()) {
                 foreach ($item->getChildren() as $child) {
                     if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
                         $freeBoxes += $item->getQty() * $child->getQty();
                     }
                 }
             } elseif ($item->getFreeShipping()) {
                 $freeBoxes += $item->getQty();
             }
         }
     }
     $this->setFreeBoxes($freeBoxes);
     $result = Mage::getModel('shipping/rate_result');
     // this one check whether shipping will be calculated per order wise
     if ($this->getConfigData('type') == 'O') {
         $shippingPrice = $this->getConfigData('price');
     } elseif ($this->getConfigData('type') == 'I') {
         $shippingPrice = $request->getPackageQty() * $this->getConfigData('price') - $this->getFreeBoxes() * $this->getConfigData('price');
     } else {
         $shippingPrice = false;
     }
     $shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
     if ($shippingPrice !== false) {
         $method = Mage::getModel('shipping/rate_result_method');
         //Set Shipping Carrier name as Express
         $method->setCarrier('express');
         //Fetch Express Shipping title which we have set from admin
         $method->setCarrierTitle($this->getConfigData('title'));
         //Set Shipping method name as express
         $method->setMethod('express');
         //Fetch Express Shipping name which we have set from admin
         $method->setMethodTitle($this->getConfigData('name'));
         /*
         	Check whether any free shipping promotion is being applied or not
         	if free shipping applied, below condition make the shipping price as 0
         */
         if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
             $shippingPrice = '0.00';
         }
         /*
         	set shipping Price and Cost as mention in admin configuration or Zero if any free shipping 
         	promotion rule is applied
         */
         $method->setPrice($shippingPrice);
         $method->setCost($shippingPrice);
         /* Append this shipping method with other shipping method which are in Enable state */
         $result->append($method);
     }
     return $result;
 }
开发者ID:sagmahajan,项目名称:aswan_release,代码行数:72,代码来源:Express.php

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

示例13: 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;
     }
     $freeBoxes = 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()) {
                         $freeBoxes += $item->getQty() * $child->getQty();
                     }
                 }
             } elseif ($item->getFreeShipping()) {
                 $freeBoxes += $item->getQty();
             }
         }
     }
     $this->setFreeBoxes($freeBoxes);
     $result = Mage::getModel('shipping/rate_result');
     if ($this->getConfigData('type') == 'O') {
         // per order
         $shippingPrice = $this->getConfigData('price');
     } elseif ($this->getConfigData('type') == 'I') {
         // per item
         $shippingPrice = $request->getPackageQty() * $this->getConfigData('price') - $this->getFreeBoxes() * $this->getConfigData('price');
     } else {
         $shippingPrice = false;
     }
     //$shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
     $custom_ship = $this->get_pro_ship();
     /*Mage::getSingleton('core/session', array('name'=>'frontend'));
      	$session = Mage::getSingleton('checkout/session');
      	$cart_items = $session->getQuote()->getAllItems();
      	$_helper = Mage::helper('catalog/output');
      	$product_shipping_price=0;
          $flat_shipping_price = 0;
          foreach( $cart_items as $items ){
           $cur_fproduct = Mage::getModel('catalog/product')->load($items->getProduct_id());
           $product_shipping_price = $_helper->productAttribute($cur_fproduct, $cur_fproduct->getShippingFlatratePerProduct(), 'shipping_flatrate_per_product');
           if ($product_shipping_price == '') {
               $flat_shipping_price += ($items) * ($this->getConfigData('price'));
           }
       }*/
     //$shippingPrice = $custom_ship + $flat_shipping_price;
     $shippingPrice = $custom_ship;
     if ($shippingPrice !== false) {
         $method = Mage::getModel('shipping/rate_result_method');
         $method->setCarrier('flatrate');
         $method->setCarrierTitle($this->getConfigData('title'));
         $method->setMethod('flatrate');
         $method->setMethodTitle($this->getConfigData('name'));
         if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
             $shippingPrice = '0.00';
         }
         $method->setPrice($shippingPrice);
         $method->setCost($shippingPrice);
         $result->append($method);
     }
     return $result;
 }
开发者ID:VinuWebtech,项目名称:production267,代码行数:71,代码来源:Flatrate.php

示例14: 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);
             }
         }
     }
     if (!$request->getMRConditionName()) {
         $request->setMRConditionName($this->getConfigData('condition_name') ? $this->getConfigData('condition_name') : $this->_default_condition_name);
     }
     // Package weight and qty free shipping
     $oldWeight = $request->getPackageWeight();
     $oldQty = $request->getPackageQty();
     if ($this->getConfigData('allow_free_shipping_promotions') && !$this->getConfigData('include_free_ship_items')) {
         $request->setPackageWeight($request->getFreeMethodWeight());
         $request->setPackageQty($oldQty - $freeQty);
     }
     $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['price'] >= 0) {
             $method = Mage::getModel('shipping/rate_result_method');
             $method->setCarrier('matrixrate');
             $method->setCarrierTitle($this->getConfigData('title'));
             $method->setMethod('matrixrate_' . $rate['pk']);
             $method->setMethodTitle(Mage::helper('matrixrate')->__($rate['delivery_type']));
             $shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
             $method->setCost($rate['cost']);
             $method->setDeliveryType($rate['delivery_type']);
             $method->setPrice($shippingPrice);
             $result->append($method);
         }
     }
     return $result;
 }
开发者ID:cabrerabywaters,项目名称:magentoSunshine,代码行数:93,代码来源:Matrixrate.php

示例15: _getProductionShipmentFields

 private function _getProductionShipmentFields(Mage_Shipping_Model_Rate_Request $mgrequest)
 {
     $regionId = $mgrequest->getRegionId();
     $region = Mage::getModel('directory/region')->load($regionId);
     $request->Shipment->SenderInformation->Address->Name = "Aaron Summer";
     //$request->Shipment->SenderInformation->Address->StreetNumber = "1234";
     $request->Shipment->SenderInformation->Address->StreetName = $mgrequest->getStreet();
     $request->Shipment->SenderInformation->Address->City = $mgrequest->getCity();
     $request->Shipment->SenderInformation->Address->Province = $region->getCode();
     $request->Shipment->SenderInformation->Address->Country = $mgrequest->getCountryId();
     $request->Shipment->SenderInformation->Address->PostalCode = $mgrequest->getPostcode();
     $request->Shipment->SenderInformation->Address->PhoneNumber->CountryCode = "1";
     $request->Shipment->SenderInformation->Address->PhoneNumber->AreaCode = "905";
     $request->Shipment->SenderInformation->Address->PhoneNumber->Phone = substr("123456789", -7);
     //Populate the Desination Information
     $request->Shipment->ReceiverInformation->Address->Name = "Aaron Summer";
     $request->Shipment->ReceiverInformation->Address->StreetName = $mgrequest->getDestStreet();
     $request->Shipment->ReceiverInformation->Address->City = $mgrequest->getDestCity();
     $regionId = $mgrequest->getDestRegionId();
     $region = Mage::getModel('directory/region')->load($regionId);
     $request->Shipment->ReceiverInformation->Address->Province = $region->getCode();
     $request->Shipment->ReceiverInformation->Address->Country = $mgrequest->getDestCountryId();
     $request->Shipment->ReceiverInformation->Address->PostalCode = $mgrequest->getDestPostcode();
     $request->Shipment->ReceiverInformation->Address->PhoneNumber->CountryCode = "1";
     $request->Shipment->ReceiverInformation->Address->PhoneNumber->AreaCode = "604";
     $request->Shipment->ReceiverInformation->Address->PhoneNumber->Phone = substr("123456789", -7);
     //Future Dated Shipments - YYYY-MM-DD format
     $request->Shipment->ShipmentDate = Mage::getModel('core/date')->date('Y-m-d');
     //Populate the Package Information
     $request->Shipment->PackageInformation->TotalWeight->Value = $mgrequest->getPackageWeight();
     $request->Shipment->PackageInformation->TotalWeight->WeightUnit = "lb";
     $request->Shipment->PackageInformation->TotalPieces = $mgrequest->getPackageQty();
     $request->Shipment->PackageInformation->ServiceID = "PurolatorExpress";
     //Populate the Payment Information
     $request->Shipment->PaymentInformation->PaymentType = "Sender";
     $request->Shipment->PaymentInformation->BillingAccountNumber = $this->BILLING_ACCOUNT;
     $request->Shipment->PaymentInformation->RegisteredAccountNumber = $this->REGISTERED_ACCOUNT;
     //Populate the Pickup Information
     $request->Shipment->PickupInformation->PickupType = "DropOff";
     $request->ShowAlternativeServicesIndicator = "true";
     //OriginSignatureNotRequired
     $request->Shipment->PackageInformation->OptionsInformation->Options->OptionIDValuePair->ID = "OriginSignatureNotRequired";
     $request->Shipment->PackageInformation->OptionsInformation->Options->OptionIDValuePair->Value = "true";
     return $request;
 }
开发者ID:platonicsolution,项目名称:local-server,代码行数:45,代码来源:Purolator.php


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