我可以使用Magento实现以下目标:
我正在使用价格与目的地的表费率系统.我有一个购物车价格规则免费送货的产品属性free_shipping - >设置是.
如果你在篮子里有正常的产品或在篮子里免费送货产品,这种方法很好.但是,如果您同时拥有正常产品和免费送货产品.它根据订单总额计算运费,包括免费送货的产品.
我该如何纠正这个问题,因此当这两种产品都存在于购物篮中时,运费仅适用于不包括免费送货的产品订单总数?
有没有Magento插件吗?提前致谢.
我遇到了同样的问题并实现了一个小的代码更改以使其工作。
基本上忘记了晋升规则。禁用它。当对个别商品应用免费送货时,它似乎无法与运费表正常配合。运输规则似乎优先并根据购物车总数计算。
诀窍是在运费模块进行计算时从购物车总数中减去免费送货的商品。
就我而言,特定类别(id:15)内的所有内容都可以免费送货。但您可以修改逻辑以满足您的需要。
您将需要修改以下文件(或将其复制到本地代码库以正确执行操作)。
应用\代码\核心\法师\运输\模型\承运人\Tablerate.php
改变这个:
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());
}
}
}
Run Code Online (Sandbox Code Playgroud)
对此:
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
//And Exclude items which should have Free Shipping
if (!$this->getConfigFlag('include_virtual_price') && $request->getAllItems()) {
$freeshipping_category_id = 15;
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());
}
//If it's in the free shipping, remove it's value from the basket
$arr_category_ids = $child->getProduct()->getCategoryIds();
if ( in_array($freeshipping_category_id, $arr_category_ids) ) {
$request->setPackageValue($request->getPackageValue() - $child->getBaseRowTotal());
}
}
} elseif ($item->getProduct()->isVirtual()) {
$request->setPackageValue($request->getPackageValue() - $item->getBaseRowTotal());
}
//If it's in the free shipping category, remove it's value from the basket
$arr_category_ids = $item->getProduct()->getCategoryIds();
if ( in_array($freeshipping_category_id, $arr_category_ids) ) {
$request->setPackageValue($request->getPackageValue() - $item->getBaseRowTotal());
}
}
}
Run Code Online (Sandbox Code Playgroud)