本文介绍了根据订单金额统一运费的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想配置商店的送货方式,以便我们根据订单总额收取统一费用.例子 :$ 0-$ 24-> $ 10运费,$ 25-$ 49-> $ 5运费,
I would like to configure our store's shipping option so that we charge a flat rate based on the order total.Example :$0 - $24 -> $10 shipping,$25 - $49 -> $5 shipping,
推荐答案
如果想统一费率,然后使用处理过程
if want to flat rate then used proccess
第一步:将app\code\copy\Mage\Shipping\Model\Carrier\Flatrate.php
复制到
app\code\local\Mage\Shipping\Model\Carrier\Flatrate.php
Step2:修改collectRates函数
Step2: modify collectRates function
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
if(($request->getBaseSubtotalInclTax() > 24) && ($request->getBaseSubtotalInclTax() <50) ){
$shippingPrice=5;
}
elseif(($request->getBaseSubtotalInclTax() > 0) && ($request->getBaseSubtotalInclTax() <25)){
$shippingPrice=10;
}else{
$shippingPrice = $this->getConfigData('price');
}
} elseif ($this->getConfigData('type') == 'I') { // per item
if(($request->getBaseSubtotalInclTax() > 24) && ($request->getBaseSubtotalInclTax() <50) ){
$shippingPricetmp=5;
}
elseif(($request->getBaseSubtotalInclTax() > 0) && ($request->getBaseSubtotalInclTax() <25)){
$shippingPricetmp=10;
}else{
$shippingPricetmp = $this->getConfigData('price');
}
$shippingPrice = ($request->getPackageQty() * $shippingPricetmp) - ($this->getFreeBoxes() * $shippingPricetmp);
} else {
$shippingPrice = false;
}
$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;
}
这篇关于根据订单金额统一运费的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!