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


PHP Mage_Shipping_Model_Rate_Request::getPackagePhysicalValue方法代码示例

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


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

示例1: setRequest

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

示例2: setRequest

 public function setRequest(Mage_Shipping_Model_Rate_Request $request)
 {
     $this->_request = $request;
     $r = new Varien_Object();
     if ($request->getLimitMethod()) {
         $r->setService($request->getLimitMethod());
     }
     if ($request->getFedexAccount()) {
         $account = $request->getFedexAccount();
     } else {
         $account = $this->getConfigData('account');
     }
     $r->setAccount($account);
     if ($request->getFedexDropoff()) {
         $dropoff = $request->getFedexDropoff();
     } else {
         $dropoff = $this->getConfigData('dropoff');
     }
     $r->setDropoffType($dropoff);
     if ($request->getFedexPackaging()) {
         $packaging = $request->getFedexPackaging();
     } else {
         $packaging = $this->getConfigData('packaging');
     }
     $r->setPackaging($packaging);
     if ($request->getOrigCountry()) {
         $origCountry = $request->getOrigCountry();
     } else {
         $origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
     }
     $r->setOrigCountry(Mage::getModel('directory/country')->load($origCountry)->getIso2Code());
     if ($request->getOrigPostcode()) {
         $r->setOrigPostal($request->getOrigPostcode());
     } else {
         $r->setOrigPostal(Mage::getStoreConfig('shipping/origin/postcode', $this->getStore()));
     }
     if ($request->getDestCountryId()) {
         $destCountry = $request->getDestCountryId();
     } else {
         $destCountry = self::USA_COUNTRY_ID;
     }
     $r->setDestCountry(Mage::getModel('directory/country')->load($destCountry)->getIso2Code());
     if ($request->getDestPostcode()) {
         $r->setDestPostal($request->getDestPostcode());
     } else {
     }
     $weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
     $r->setWeight($weight);
     if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
         $r->setFreeMethodWeight($request->getFreeMethodWeight());
     }
     $r->setValue($request->getPackagePhysicalValue());
     $r->setValueWithDiscount($request->getPackageValueWithDiscount());
     $this->_rawRequest = $r;
     return $this;
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:56,代码来源:Fedex.php

示例3: getMethods

 /**
  * 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 getMethods(Mage_Shipping_Model_Rate_Request $request, $my_code = false)
 {
     $dest_country = $request->getDestCountryId();
     $dest_region = $request->getDestRegionId();
     $package_value = $request->getPackageValue();
     $shipping_price = 0;
     // 			Mage::log($request->debug(), null, 'test.log');
     // 			Mage::log($exception_regions, null, 'test.log');
     // 			Mage::log($dest_country, null, 'test.log');
     // 			Mage::log($dest_region, null, 'test.log');
     $i = 1;
     $max_price = 0;
     $items = array();
     $cart_products_price_reduction = 0;
     if ($_items = $request->getAllItems()) {
         foreach ($_items as $item) {
             // 					if($item->getProductType() != 'simple') continue;
             // 					Mage::log($i++, null, 'test.log');
             // 					Mage::log($item->debug(), null, 'test.log');
             if ($parent_item_id = $item->getParentItemId()) {
                 continue;
                 // 							$items[$item_id]['free_shipping'] = $item->getMaxFreeShipping();
                 // 							$items[$item_id]['primary_shipping'] = $item->getMaxPrimaryShip();
                 // 							$items[$item_id]['secondary_shipping'] = $item->getMaxSecondaryShip();
             } elseif ($item->getProductType() == 'cartproduct') {
                 continue;
             }
             $p = Mage::getModel('catalog/product')->load($item->getProductId());
             $item_id = $item->getItemId();
             $items[$item_id]['price'] = $item->getPrice();
             $items[$item_id]['sku'] = $item->getSku();
             $items[$item_id]['qty'] = $item->getQty();
             $items[$item_id]['free_shipping'] = $p->getMaxFreeShipping();
             $items[$item_id]['primary_shipping'] = $p->getMaxPrimaryShip();
             $items[$item_id]['secondary_shipping'] = $p->getMaxSecondaryShip();
             if ($item->getPrice() >= $max_price) {
                 $max_price = $item->getPrice();
                 $max_id = $item_id;
             }
             // 					$p = Mage::getModel('catalog/product')->load($item->getProductId());
             // 					$tmp_price = (float) $p->getFreightShipTotal();
             // 					Mage::log($p->getData(), null, 'test.log');
             //          Mage::log($item->debug(), null, 'test.log');
         }
     }
     foreach ($items as $item_id => $item) {
         $qty = (int) $item['qty'];
         $max_done = false;
         for ($i = 1; $i <= $qty; $i++) {
             if (!$max_done && $item_id == $max_id) {
                 $shipping_price += $item['free_shipping'] ? 0 : (double) $item['primary_shipping'];
                 $max_done = true;
                 continue;
             }
             $shipping_price += $item['free_shipping'] ? 0 : (double) $item['secondary_shipping'];
         }
     }
     // 199.5 + 105 + 210
     if ($dest_country == 'CA') {
         $item_percent = (double) Mage::getStoreConfig('carriers/maxshipping/canadian_percent') / 100;
         $duty = (double) Mage::getStoreConfig('carriers/maxshipping/canadian_duty') / 100;
         $tax = (double) Mage::getStoreConfig('carriers/maxshipping/canadian_tax') / 100;
         $shipping_price += $request->getPackagePhysicalValue() * $item_percent;
         $shipping_price += $request->getPackagePhysicalValue() * $duty;
         $shipping_price += $request->getPackagePhysicalValue() * $tax;
         $shipping_price += (double) Mage::getStoreConfig('carriers/maxshipping/canadian_border_fee');
     }
     $methods = array();
     // 			$label = Mage::getStoreConfig('carriers/maxshipping/title');
     $method = Mage::getModel('shipping/rate_result_method');
     $method->setMethodTitle('');
     $method->setCarrier($this->_code);
     $method->setMethod('standard');
     $method->setPrice($shipping_price);
     $methods[] = $method;
     // 			Mage::log($methods, null, 'methods.log');
     return $methods;
 }
开发者ID:jokusafet,项目名称:MagentoSource,代码行数:84,代码来源:Maxshipping.php

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


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