本文整理汇总了PHP中Mage_Shipping_Model_Rate_Request::getFreeMethodWeight方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Shipping_Model_Rate_Request::getFreeMethodWeight方法的具体用法?PHP Mage_Shipping_Model_Rate_Request::getFreeMethodWeight怎么用?PHP Mage_Shipping_Model_Rate_Request::getFreeMethodWeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Shipping_Model_Rate_Request
的用法示例。
在下文中一共展示了Mage_Shipping_Model_Rate_Request::getFreeMethodWeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
//.........这里部分代码省略.........
示例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());
} else {
$r->setService('ALL');
}
if ($request->getUspsUserid()) {
$userId = $request->getUspsUserid();
} else {
$userId = $this->getConfigData('userid');
}
$r->setUserId($userId);
if ($request->getUspsContainer()) {
$container = $request->getUspsContainer();
} else {
$container = $this->getConfigData('container');
}
$r->setContainer($container);
if ($request->getUspsSize()) {
$size = $request->getUspsSize();
} else {
$size = $this->getConfigData('size');
}
$r->setSize($size);
if ($request->getUspsMachinable()) {
$machinable = $request->getUspsMachinable();
} else {
$machinable = $this->getConfigData('machinable');
}
$r->setMachinable($machinable);
if ($request->getOrigPostcode()) {
$r->setOrigPostal($request->getOrigPostcode());
} else {
$r->setOrigPostal(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_POSTCODE, $this->getStore()));
}
if ($request->getDestCountryId()) {
$destCountry = $request->getDestCountryId();
} else {
$destCountry = self::USA_COUNTRY_ID;
}
$r->setDestCountryId($destCountry);
if (!$this->_isUSCountry($destCountry)) {
$r->setDestCountryName($this->_getCountryName($destCountry));
}
if ($request->getDestPostcode()) {
$r->setDestPostal($request->getDestPostcode());
}
$weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
$r->setWeightPounds(floor($weight));
$r->setWeightOunces(round(($weight - floor($weight)) * 16, 1));
if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
$r->setFreeMethodWeight($request->getFreeMethodWeight());
}
$r->setValue($request->getPackageValue());
$r->setValueWithDiscount($request->getPackageValueWithDiscount());
$this->_rawRequest = $r;
return $this;
}
示例3: 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;
}
示例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);
//.........这里部分代码省略.........
示例5: _updateFreeMethodQuote
/**
* @param Mage_Shipping_Model_Rate_Request $request
* @return null
*/
protected function _updateFreeMethodQuote($request)
{
if ($request->getFreeMethodWeight() == $request->getPackageWeight() || !$request->hasFreeMethodWeight()) {
return;
}
$freeMethod = $this->getConfigData('free_method');
if (!$freeMethod) {
return;
}
$freeRateId = false;
if (is_object($this->_result)) {
foreach ($this->_result->getAllRates() as $i => $item) {
if ($item->getMethod() == $freeMethod) {
$freeRateId = $i;
break;
}
}
}
if ($freeRateId === false) {
return;
}
$price = null;
if ($request->getFreeMethodWeight() > 0) {
$this->_setFreeMethodRequest($freeMethod);
$result = $this->_getQuotes();
if ($result && ($rates = $result->getAllRates()) && count($rates) > 0) {
if (count($rates) == 1 && $rates[0] instanceof Mage_Shipping_Model_Rate_Result_Method) {
$price = $rates[0]->getPrice();
}
if (count($rates) > 1) {
foreach ($rates as $rate) {
if ($rate instanceof Mage_Shipping_Model_Rate_Result_Method && $rate->getMethod() == $freeMethod) {
$price = $rate->getPrice();
}
}
}
}
} else {
/**
* if we can apply free shipping for all order we should force price
* to $0.00 for shipping with out sending second request to carrier
*/
$price = 0;
}
/**
* if we did not get our free shipping method in response we must use its old price
*/
if (!is_null($price)) {
$this->_result->getRateById($freeRateId)->setPrice($price);
}
}
示例6: setRequest
/**
* Prepare and set request to this instance
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return Mage_Usa_Model_Shipping_Carrier_Usps
*/
public function setRequest(Mage_Shipping_Model_Rate_Request $request)
{
$this->_request = $request;
$r = new Varien_Object();
if ($request->getLimitMethod()) {
$r->setService($request->getLimitMethod());
} else {
$r->setService('ALL');
}
if ($request->getUspsUserid()) {
$userId = $request->getUspsUserid();
} else {
$userId = $this->getConfigData('userid');
}
$r->setUserId($userId);
if ($request->getUspsContainer()) {
$container = $request->getUspsContainer();
} else {
$container = $this->getConfigData('container');
}
$r->setContainer($container);
if ($request->getUspsSize()) {
$size = $request->getUspsSize();
} else {
$size = $this->getConfigData('size');
}
$r->setSize($size);
if ($request->getGirth()) {
$girth = $request->getGirth();
} else {
$girth = $this->getConfigData('girth');
}
$r->setGirth($girth);
if ($request->getHeight()) {
$height = $request->getHeight();
} else {
$height = $this->getConfigData('height');
}
$r->setHeight($height);
if ($request->getLength()) {
$length = $request->getLength();
} else {
$length = $this->getConfigData('length');
}
$r->setLength($length);
if ($request->getWidth()) {
$width = $request->getWidth();
} else {
$width = $this->getConfigData('width');
}
$r->setWidth($width);
if ($request->getUspsMachinable()) {
$machinable = $request->getUspsMachinable();
} else {
$machinable = $this->getConfigData('machinable');
}
$r->setMachinable($machinable);
if ($request->getOrigPostcode()) {
$r->setOrigPostal($request->getOrigPostcode());
} else {
$r->setOrigPostal(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, $request->getStoreId()));
}
if ($request->getOrigCountryId()) {
$r->setOrigCountryId($request->getOrigCountryId());
} else {
$r->setOrigCountryId(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $request->getStoreId()));
}
if ($request->getDestCountryId()) {
$destCountry = $request->getDestCountryId();
} else {
$destCountry = self::USA_COUNTRY_ID;
}
$r->setDestCountryId($destCountry);
if (!$this->_isUSCountry($destCountry)) {
$r->setDestCountryName($this->_getCountryName($destCountry));
}
if ($request->getDestPostcode()) {
$r->setDestPostal($request->getDestPostcode());
}
$weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
$r->setWeightPounds(floor($weight));
$r->setWeightOunces(round(($weight - floor($weight)) * self::OUNCES_POUND, 1));
if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
$r->setFreeMethodWeight($request->getFreeMethodWeight());
}
$r->setValue($request->getPackageValue());
$r->setValueWithDiscount($request->getPackageValueWithDiscount());
$r->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax());
$this->_rawRequest = $r;
return $this;
}
示例7: _updateFreeMethodQuote
/**
* Override this for Shipwire. We only quote $0 shipping cost if all the items in the cart qualify for free shipping
* @param Mage_Shipping_Model_Rate_Request $request
* @return null
*/
protected function _updateFreeMethodQuote($request)
{
// echo "getFreeMethodWeight: " . $request->getFreeMethodWeight();
// echo "hasFreeMethodWeight: " . $request->hasFreeMethodWeight();
// echo "getPackageWeight: " . $request->getPackageWeight();
if ($request->getFreeMethodWeight() == $request->getPackageWeight() || !$request->hasFreeMethodWeight()) {
return;
}
$freeMethod = $this->getConfigData($this->_freeMethod);
if (!$freeMethod) {
return;
}
$freeRateId = false;
if (is_object($this->_result)) {
foreach ($this->_result->getAllRates() as $i => $item) {
if ($item->getMethod() == $freeMethod) {
$freeRateId = $i;
break;
}
}
}
if ($freeRateId === false) {
return;
}
if ($request->getFreeMethodWeight() == 0) {
// If the entire order has no weight because it is free then set the price to 0
$this->_result->getRateById($freeRateId)->setPrice(0);
}
}
示例8: setRequest
public function setRequest(Mage_Shipping_Model_Rate_Request $request)
{
$this->_request = $request;
$r = new Varien_Object();
if ($request->getLimitMethod()) {
$r->setService($request->getLimitMethod());
} else {
$r->setService('ALL');
}
if ($request->getUspsUserid()) {
$userId = $request->getUspsUserid();
} else {
$userId = $this->getConfigData('userid');
}
$r->setUserId($userId);
if ($request->getUspsContainer()) {
$container = $request->getUspsContainer();
} else {
$container = $this->getConfigData('container');
}
$r->setContainer($container);
if ($request->getUspsSize()) {
$size = $request->getUspsSize();
} else {
$size = $this->getConfigData('size');
}
$r->setSize($size);
if ($request->getUspsMachinable()) {
$machinable = $request->getUspsMachinable();
} else {
$machinable = $this->getConfigData('machinable');
}
$r->setMachinable($machinable);
if ($request->getOrigPostcode()) {
$r->setOrigPostal($request->getOrigPostcode());
} else {
$r->setOrigPostal(Mage::getStoreConfig('shipping/origin/postcode'));
}
if ($request->getDestCountryId()) {
$destCountry = $request->getDestCountryId();
} else {
$destCountry = self::USA_COUNTRY_ID;
}
$r->setDestCountryId($destCountry);
/*
for GB, we cannot use United Kingdom
*/
if ($destCountry == 'GB') {
$countryName = 'Great Britain and Northern Ireland';
} else {
$countries = Mage::getResourceModel('directory/country_collection')->addCountryIdFilter($destCountry)->load()->getItems();
$country = array_shift($countries);
$countryName = $country->getName();
}
$r->setDestCountryName($countryName);
if ($request->getDestPostcode()) {
$r->setDestPostal($request->getDestPostcode());
}
$weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
$r->setWeightPounds(floor($weight));
$r->setWeightOunces(round(($weight - floor($weight)) * 16, 1));
if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
$r->setFreeMethodWeight($request->getFreeMethodWeight());
}
$r->setValue($request->getPackageValue());
$r->setValueWithDiscount($request->getPackageValueWithDiscount());
$this->_rawRequest = $r;
return $this;
}
示例9: setRequest
/**
* Prepare and set request to this instance
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return Curkle_EasyPost_Model_Carrier_Easypost
*/
public function setRequest(Mage_Shipping_Model_Rate_Request $request)
{
$this->_request = $request;
$r = new Varien_Object();
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->getOrigRegionCode()) {
$origRegionCode = $request->getOrigRegionCode();
} else {
$origRegionCode = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_REGION_ID, $request->getStoreId());
}
if (is_numeric($origRegionCode)) {
$origRegionCode = Mage::getModel('directory/region')->load($origRegionCode)->getCode();
}
$r->setOrigRegionCode($origRegionCode);
if ($request->getOrigPostcode()) {
$r->setOrigPostal($request->getOrigPostcode());
} else {
$r->setOrigPostal(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, $request->getStoreId()));
}
if ($request->getOrigCity()) {
$r->setOrigCity($request->getOrigCity());
} else {
$r->setOrigCity(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_CITY, $request->getStoreId()));
}
if ($request->getDestCountryId()) {
$destCountry = $request->getDestCountryId();
} else {
$destCountry = self::USA_COUNTRY_ID;
}
$r->setDestCountry(Mage::getModel('directory/country')->load($destCountry)->getIso2Code());
$r->setDestRegionCode($request->getDestRegionCode());
if ($request->getDestPostcode()) {
$r->setDestPostal($request->getDestPostcode());
} else {
}
$weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
$weight = $this->_getCorrectWeight($weight);
$r->setWeight($weight);
if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
$r->setFreeMethodWeight($request->getFreeMethodWeight());
}
$r->setValue($request->getPackageValue());
$r->setValueWithDiscount($request->getPackageValueWithDiscount());
if ($request->getUpsUnitMeasure()) {
$unit = $request->getUpsUnitMeasure();
} else {
$unit = $this->getConfigData('unit_of_measure');
}
$r->setUnitMeasure($unit);
$r->setIsReturn($request->getIsReturn());
$r->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax());
$this->_rawRequest = $r;
return $this;
}
示例10: setRequest
public function setRequest(Mage_Shipping_Model_Rate_Request $request)
{
$this->_request = $request;
$r = new Varien_Object();
if ($request->getLimitMethod()) {
$r->setAction($this->getCode('action', 'single'));
$r->setProduct($request->getLimitMethod());
} else {
$r->setAction($this->getCode('action', 'all'));
$r->setProduct('GND' . $this->getConfigData('dest_type'));
}
if ($request->getUpsPickup()) {
$pickup = $request->getUpsPickup();
} else {
$pickup = $this->getConfigData('pickup');
}
$r->setPickup($this->getCode('pickup', $pickup));
if ($request->getUpsContainer()) {
$container = $request->getUpsContainer();
} else {
$container = $this->getConfigData('container');
}
$r->setContainer($this->getCode('container', $container));
if ($request->getUpsDestType()) {
$destType = $request->getUpsDestType();
} else {
$destType = $this->getConfigData('dest_type');
}
$r->setDestType($this->getCode('dest_type', $destType));
if ($request->getOrigCountry()) {
$origCountry = $request->getOrigCountry();
} else {
$origCountry = AO::getStoreConfig('shipping/origin/country_id', $this->getStore());
}
$r->setOrigCountry(AO::getModel('directory/country')->load($origCountry)->getIso2Code());
if ($request->getOrigRegionCode()) {
$origRegionCode = $request->getOrigRegionCode();
} else {
$origRegionCode = AO::getStoreConfig('shipping/origin/region_id', $this->getStore());
if (is_numeric($origRegionCode)) {
$origRegionCode = AO::getModel('directory/region')->load($origRegionCode)->getCode();
}
}
$r->setOrigRegionCode($origRegionCode);
if ($request->getOrigPostcode()) {
$r->setOrigPostal($request->getOrigPostcode());
} else {
$r->setOrigPostal(AO::getStoreConfig('shipping/origin/postcode', $this->getStore()));
}
if ($request->getOrigCity()) {
$r->setOrigCity($request->getOrigCity());
} else {
$r->setOrigCity(AO::getStoreConfig('shipping/origin/city', $this->getStore()));
}
if ($request->getDestCountryId()) {
$destCountry = $request->getDestCountryId();
} else {
$destCountry = self::USA_COUNTRY_ID;
}
//for UPS, puero rico state for US will assume as puerto rico country
if ($destCountry == self::USA_COUNTRY_ID && ($request->getDestPostcode() == '00912' || $request->getDestRegionCode() == self::PUERTORICO_COUNTRY_ID)) {
$destCountry = self::PUERTORICO_COUNTRY_ID;
}
$r->setDestCountry(AO::getModel('directory/country')->load($destCountry)->getIso2Code());
$r->setDestRegionCode($request->getDestRegionCode());
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->getPackageValue());
$r->setValueWithDiscount($request->getPackageValueWithDiscount());
if ($request->getUpsUnitMeasure()) {
$unit = $request->getUpsUnitMeasure();
} else {
$unit = $this->getConfigData('unit_of_measure');
}
$r->setUnitMeasure($unit);
$this->_rawRequest = $r;
return $this;
}
示例11: _updateFreeMethodQuote
/**
* WebShopApps - Changed to support Free Shipping using either Ground or Home Delivery
* @param Mage_Shipping_Model_Rate_Request $request
* @return null
*/
protected function _updateFreeMethodQuote($request)
{
if ($request->getFreeMethodWeight() == $request->getPackageWeight() || !$request->hasFreeMethodWeight()) {
return;
}
$freeCode = Mage::helper('wsacommon')->getNewVersion() < 12 ? 'free_method' : $this->_freeMethod;
$freeMethod = $this->getConfigData($freeCode);
if (!$freeMethod) {
return;
}
$freeRateId = false;
$matchFedexGround = false;
if ($this->getConfigData('free_both_ground')) {
if ($freeMethod == 'GROUND_HOME_DELIVERY') {
$altMethod = 'FEDEX_GROUND';
$matchFedexGround = true;
} else {
if ($freeMethod == 'FEDEX_GROUND') {
// could match on either, need to check
$altMethod = 'GROUND_HOME_DELIVERY';
$matchFedexGround = true;
}
}
}
if (is_object($this->_result)) {
foreach ($this->_result->getAllRates() as $i => $item) {
if ($item->getMethod() == $freeMethod || $matchFedexGround && $item->getMethod() == $altMethod) {
$freeRateId = $i;
break;
}
}
}
if ($freeRateId === false) {
return;
}
$price = null;
if ($request->getFreeMethodWeight() > 0) {
$this->_setFreeMethodRequest($freeMethod);
$result = $this->_getQuotes();
if ($result && ($rates = $result->getAllRates()) && count($rates) > 0) {
if (count($rates) == 1 && $rates[0] instanceof Mage_Shipping_Model_Rate_Result_Method) {
$price = $rates[0]->getPrice();
}
if (count($rates) > 1) {
foreach ($rates as $rate) {
if ($rate instanceof Mage_Shipping_Model_Rate_Result_Method && ($rate->getMethod() == $freeMethod || $matchFedexGround && $item->getMethod() == $altMethod)) {
$price = $rate->getPrice();
}
}
}
}
} else {
/**
* if we can apply free shipping for all order we should force price
* to $0.00 for shipping with out sending second request to carrier
*/
$price = 0;
}
/**
* if we did not get our free shipping method in response we must use its old price
*/
if (!is_null($price)) {
$this->_result->getRateById($freeRateId)->setPrice($price);
}
}
示例12: setRequest
public function setRequest(Mage_Shipping_Model_Rate_Request $request)
{
$this->_request = $request;
$r = new Varien_Object();
if ($request->getLimitMethod()) {
$r->setService($request->getLimitMethod());
} else {
$r->setService('ALL');
}
if ($request->getUspsUserid()) {
$userId = $request->getUspsUserid();
} else {
$userId = $this->getConfigData('userid');
}
$r->setUserId($userId);
if ($request->getUspsContainer()) {
$container = $request->getUspsContainer();
} else {
$container = $this->getConfigData('container');
}
$r->setContainer($container);
if ($request->getUspsSize()) {
$size = $request->getUspsSize();
} else {
$size = $this->getConfigData('size');
}
$r->setSize($size);
if ($request->getUspsMachinable()) {
$machinable = $request->getUspsMachinable();
} else {
$machinable = $this->getConfigData('machinable');
}
$r->setMachinable($machinable);
if ($request->getOrigPostcode()) {
$r->setOrigPostal($request->getOrigPostcode());
} else {
$r->setOrigPostal(Mage::getStoreConfig('shipping/origin/postcode'));
}
if ($request->getDestCountryId()) {
$destCountry = $request->getDestCountryId();
} else {
$destCountry = self::USA_COUNTRY_ID;
}
$r->setDestCountryId($destCountry);
$countries = Mage::getResourceModel('directory/country_collection')->addCountryIdFilter($destCountry)->load()->getItems();
$country = array_shift($countries);
$r->setDestCountryName($country->getName());
if ($request->getDestPostcode()) {
$r->setDestPostal($request->getDestPostcode());
} else {
}
$r->setWeightPounds(floor($request->getPackageWeight()));
$r->setWeightOunces(floor(($request->getPackageWeight() - floor($request->getPackageWeight())) * 16));
if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
$r->settFreeMethodWeightPounds(floor($request->getFreeMethodWeight()));
$r->settFreeMethodWeightOunces(($request->getFreeMethodWeight() - floor($request->getFreeMethodWeight())) * 16);
}
$r->setValue($request->getPackageValue());
$this->_rawRequest = $r;
return $this;
}
示例13: _inicialCheck
/**
* Make initial checks and iniciate module variables
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return boolean
*/
protected function _inicialCheck(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->getConfigFlag('active')) {
//Disabled
Mage::log('O2TI_Sisfrete: Disabled');
return false;
}
$origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
$destCountry = $request->getDestCountryId();
if ($origCountry != "BR" || $destCountry != "BR") {
//Out of delivery area
Mage::log('O2TI_Sisfrete: Out of delivery area');
return false;
}
// ZIP Code
$this->_fromZip = Mage::getStoreConfig('shipping/origin/postcode', $this->getStore());
$this->_toZip = $request->getDestPostcode();
//Fix Zip Code
$this->_fromZip = str_replace(array('-', '.'), '', trim($this->_fromZip));
$this->_toZip = str_replace(array('-', '.'), '', trim($this->_toZip));
if (!preg_match("/^([0-9]{8})\$/", $this->_fromZip)) {
//From zip code error
Mage::log('O2TI_Sisfrete: From ZIP Code Error');
return false;
}
// Result model
$this->_result = Mage::getModel('shipping/rate_result');
// Value
$this->_packageValue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
// Weight
$this->_packageWeight = number_format($request->getPackageWeight(), 2, '.', '');
// Free method weight
$this->_freeMethodWeight = number_format($request->getFreeMethodWeight(), 2, '.', '');
}
示例14: setRequest
public function setRequest(Mage_Shipping_Model_Rate_Request $request)
{
$this->_request = $request;
$r = new Varien_Object();
if ($request->getLimitMethod()) {
$r->setService($request->getLimitMethod());
}
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->getPackageValue());
$r->setValueWithDiscount($request->getPackageValueWithDiscount());
$this->_rawRequest = $r;
return $this;
}
示例15: _inicialCheck
/**
* Make initial checks and iniciate module variables
*
* @param Mage_Shipping_Model_Rate_Request $request Mage request
*
* @return bool
*/
protected function _inicialCheck(Mage_Shipping_Model_Rate_Request $request)
{
$this->_prepareProductsToSendFastShipping();
$this->_fromZip = Mage::getStoreConfig('shipping/origin/postcode', $this->getStore());
$this->_toZip = $request->getDestPostcode();
// Fix ZIP code
$this->_fromZip = str_replace(array('-', '.'), '', trim($this->_fromZip));
$this->_toZip = str_replace(array('-', '.'), '', trim($this->_toZip));
$this->_result = Mage::getModel('shipping/rate_result');
$this->_packageValue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
$this->_packageWeight = number_format($request->getPackageWeight(), 2, '.', '');
$this->_freeMethodWeight = number_format($request->getFreeMethodWeight(), 2, '.', '');
}