本文整理汇总了PHP中Mage_Shipping_Model_Rate_Request::setPackageValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Shipping_Model_Rate_Request::setPackageValue方法的具体用法?PHP Mage_Shipping_Model_Rate_Request::setPackageValue怎么用?PHP Mage_Shipping_Model_Rate_Request::setPackageValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Shipping_Model_Rate_Request
的用法示例。
在下文中一共展示了Mage_Shipping_Model_Rate_Request::setPackageValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: collectRates
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) {
return false;
}
$lei = Mage::helper('urgent')->isLei($request->getData('package_currency'));
if (!$lei) {
return false;
}
$helper = Mage::helper('urgent');
if ($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());
}
}
}
$valuare = $request->getPackageValue() * $lei;
if ($helper->getAfisare() == 2) {
$methodUrgent = $this->_calculateTotal($request, $valuare, true);
$result = Mage::getModel('shipping/rate_result');
$result->append($methodUrgent);
return $result;
} else {
$methodUrgent = $this->_calculateTotal($request, $valuare, false);
$result = Mage::getModel('shipping/rate_result');
$result->append($methodUrgent);
return $result;
}
}
示例3: collectRates
/**
* Enter description here...
*
* @param Mage_Shipping_Model_Rate_Request $data
* @return Mage_Shipping_Model_Rate_Result
*/
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->getConfigFlag('active')) {
return false;
}
// exclude Virtual products price from Package value if pre-configured
if (!$this->getConfigFlag('include_virtual_price') && $request->getAllItems()) {
foreach ($request->getAllItems() as $item) {
if ($item->getParentItem()) {
continue;
}
if ($item->getHasChildren() && $item->isShipSeparately()) {
foreach ($item->getChildren() as $child) {
if ($child->getProduct()->isVirtual()) {
$request->setPackageValue($request->getPackageValue() - $child->getBaseRowTotal());
}
}
} elseif ($item->getProduct()->isVirtual()) {
$request->setPackageValue($request->getPackageValue() - $item->getBaseRowTotal());
}
}
}
// Free shipping by qty
$freeQty = 0;
if ($request->getAllItems()) {
foreach ($request->getAllItems() as $item) {
if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
continue;
}
if ($item->getHasChildren() && $item->isShipSeparately()) {
foreach ($item->getChildren() as $child) {
if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
$freeQty += $item->getQty() * ($child->getQty() - (is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0));
}
}
} elseif ($item->getFreeShipping()) {
$freeQty += $item->getQty() - (is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0);
}
}
}
if (!$request->getConditionName()) {
$request->setConditionName($this->getConfigData('condition_name') ? $this->getConfigData('condition_name') : $this->_default_condition_name);
}
// Package weight and qty free shipping
$oldWeight = $request->getPackageWeight();
$oldQty = $request->getPackageQty();
$request->setPackageWeight($request->getFreeMethodWeight());
$request->setPackageQty($oldQty - $freeQty);
$result = Mage::getModel('Mage_Shipping_Model_Rate_Result');
$rate = $this->getRate($request);
$request->setPackageWeight($oldWeight);
$request->setPackageQty($oldQty);
if (!empty($rate) && $rate['price'] >= 0) {
$method = Mage::getModel('Mage_Shipping_Model_Rate_Result_Method');
$method->setCarrier('tablerate');
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethod('bestway');
$method->setMethodTitle($this->getConfigData('name'));
if ($request->getFreeShipping() === true || $request->getPackageQty() == $freeQty) {
$shippingPrice = 0;
} else {
$shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
}
$method->setPrice($shippingPrice);
$method->setCost($rate['cost']);
$result->append($method);
}
return $result;
}
示例4: collectRates
/**
* Collect and get rates
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return Mage_Shipping_Model_Rate_Result
*/
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->getConfigFlag('active')) {
return false;
}
// exclude Virtual products price from Package value if pre-configured
if (!$this->getConfigFlag('include_virtual_price') && $request->getAllItems()) {
foreach ($request->getAllItems() as $item) {
if ($item->getParentItem()) {
continue;
}
if ($item->getHasChildren() && $item->isShipSeparately()) {
foreach ($item->getChildren() as $child) {
if ($child->getProduct()->isVirtual()) {
$request->setPackageValue($request->getPackageValue() - $child->getBaseRowTotal());
}
}
} elseif ($item->getProduct()->isVirtual()) {
$request->setPackageValue($request->getPackageValue() - $item->getBaseRowTotal());
}
}
}
// Free shipping by qty
$freeQty = 0;
if ($request->getAllItems()) {
$freePackageValue = 0;
foreach ($request->getAllItems() as $item) {
if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
continue;
}
if ($item->getHasChildren() && $item->isShipSeparately()) {
foreach ($item->getChildren() as $child) {
if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
$freeShipping = is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0;
$freeQty += $item->getQty() * ($child->getQty() - $freeShipping);
}
}
} elseif ($item->getFreeShipping()) {
$freeShipping = is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0;
$freeQty += $item->getQty() - $freeShipping;
$freePackageValue += $item->getBaseRowTotal();
}
}
$oldValue = $request->getPackageValue();
$request->setPackageValue($oldValue - $freePackageValue);
}
if ($freePackageValue) {
$request->setPackageValue($request->getPackageValue() - $freePackageValue);
}
if (!$request->getConditionName()) {
$conditionName = $this->getConfigData('condition_name');
$request->setConditionName($conditionName ? $conditionName : $this->_default_condition_name);
}
// Package weight and qty free shipping
$oldWeight = $request->getPackageWeight();
$oldQty = $request->getPackageQty();
$request->setPackageWeight($request->getFreeMethodWeight());
$request->setPackageQty($oldQty - $freeQty);
$result = $this->_getModel('shipping/rate_result');
$rate = $this->getRate($request);
$request->setPackageWeight($oldWeight);
$request->setPackageQty($oldQty);
if (!empty($rate) && $rate['price'] >= 0) {
$method = $this->_getModel('shipping/rate_result_method');
$method->setCarrier('tablerate');
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethod('bestway');
$method->setMethodTitle($this->getConfigData('name'));
if ($request->getFreeShipping() === true || $request->getPackageQty() == $freeQty) {
$shippingPrice = 0;
} else {
$shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
}
$method->setPrice($shippingPrice);
$method->setCost($rate['cost']);
$result->append($method);
} elseif (empty($rate) && $request->getFreeShipping() === true) {
/**
* was applied promotion rule for whole cart
* other shipping methods could be switched off at all
* we must show table rate method with 0$ price, if grand_total more, than min table condition_value
* free setPackageWeight() has already was taken into account
*/
$request->setPackageValue($freePackageValue);
$request->setPackageQty($freeQty);
$rate = $this->getRate($request);
if (!empty($rate) && $rate['price'] >= 0) {
$method = $this->_getModel('shipping/rate_result_method');
$method->setCarrier('tablerate');
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethod('bestway');
$method->setMethodTitle($this->getConfigData('name'));
$method->setPrice(0);
$method->setCost(0);
//.........这里部分代码省略.........
示例5: 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;
}
示例6: collectRates
/**
* Collect shipping method price and set all data selected in config.
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return bool|false|Mage_Core_Model_Abstract
*/
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) {
return false;
}
$method = Mage::getModel('shipping/rate_result_method');
$result = Mage::getModel('shipping/rate_result');
if (!$this->getConfigData('ratetype')) {
$price = $this->getConfigData('flatrateprice');
if ($request->getFreeShipping() === true) {
$price = 0;
}
} else {
$freeQty = 0;
if ($request->getAllItems()) {
$freePackageValue = 0;
foreach ($request->getAllItems() as $item) {
if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
continue;
}
if ($item->getHasChildren() && $item->isShipSeparately()) {
foreach ($item->getChildren() as $child) {
if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
$freeShipping = is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0;
$freeQty += $item->getQty() * ($child->getQty() - $freeShipping);
}
}
} elseif ($item->getFreeShipping()) {
$freeShipping = is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0;
$freeQty += $item->getQty() - $freeShipping;
$freePackageValue += $item->getBaseRowTotal();
}
}
$oldValue = $request->getPackageValue();
$request->setPackageValue($oldValue - $freePackageValue);
}
if ($freePackageValue) {
$request->setPackageValue($request->getPackageValue() - $freePackageValue);
}
$conditionName = $this->getConfigData('condition_name');
$request->setConditionName($conditionName ? $conditionName : $this->_default_condition_name);
$oldWeight = $request->getPackageWeight();
$oldQty = $request->getPackageQty();
$request->setPackageWeight($request->getFreeMethodWeight());
$request->setPackageQty($oldQty - $freeQty);
$rate = $this->getRate($request);
$request->setPackageWeight($oldWeight);
$request->setPackageQty($oldQty);
if (!empty($rate) && $rate['price'] >= 0) {
if ($request->getFreeShipping() === true || $request->getPackageQty() == $freeQty) {
$price = 0;
} else {
$price = $rate['price'];
}
} elseif (empty($rate) && $request->getFreeShipping() === true) {
$request->setPackageValue($freePackageValue);
$request->setPackageQty($freeQty);
$rate = $this->getRate($request);
if (!empty($rate) && $rate['price'] >= 0) {
$price = 0;
}
} else {
$error = Mage::getModel('shipping/rate_result_error');
$error->setCarrier($this->_code);
$error->setCarrierTitle($this->getConfigData('title'));
$error->setErrorMessage(Mage::helper('dpd')->__('This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.'));
$result->append($error);
return $result;
}
}
$method->setCarrier($this->_code);
$method->setMethod($this->_code);
$method->setMethodTitle($this->getConfigData('name'));
$method->setCarrierTitle($this->getConfigData('carrier'));
$method->setPrice($price);
$method->setCost($price);
$result->append($method);
return $result;
}
示例7: 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);
//.........这里部分代码省略.........