Magento仅适用于匹配项目的免费配送-使用基于订单总额的表格费率
我能否通过Magento实现以下目标: 我使用的是一个价格和目的地的表格费率系统。对于属性为Free_Shipping->的产品,我有一个免费送货的购物车价格规则设置为yes 如果您的购物篮中有普通商品,或者购物篮中有免费送货商品,则此功能非常有效。然而,如果你有一个正常的产品和一个免费送货产品在篮子里。它根据订单总额(包括免费配送的产品)计算配送 我如何纠正这一点,因此,当篮子中存在两种类型的产品时,装运仅适用于不包括免费装运的产品订单总额Magento仅适用于匹配项目的免费配送-使用基于订单总额的表格费率,magento,shipping,Magento,Shipping,我能否通过Magento实现以下目标: 我使用的是一个价格和目的地的表格费率系统。对于属性为Free_Shipping->的产品,我有一个免费送货的购物车价格规则设置为yes 如果您的购物篮中有普通商品,或者购物篮中有免费送货商品,则此功能非常有效。然而,如果你有一个正常的产品和一个免费送货产品在篮子里。它根据订单总额(包括免费配送的产品)计算配送 我如何纠正这一点,因此,当篮子中存在两种类型的产品时,装运仅适用于不包括免费装运的产品订单总额 这有Magento插件吗?提前感谢。在您的销售规则中
这有Magento插件吗?提前感谢。在您的销售规则中,将免费送货设置为“仅适用于匹配商品”。如果我正确理解了您的问题,解决方案非常简单快捷,以下是我解决问题的方法: 在文件中:Validator.php(/app/code/core/Mage/SalesRule/Model/) 搜索字符串“case Mage\u SalesRule\u Model\u Rule::FREE\u SHIPPING\u ITEM:”并在“break”之前添加这个简单的东西“$ITEM->setWeight(0);”
这将强制物品的重量为0,因此不会对其计算运费。如果您禁用帽子物品的免费送货选项,则会考虑重量,一切正常。我也遇到了同样的问题,并实施了一个小的代码更改以使其正常工作 基本上忘记了晋升规则。禁用它。当将免费送货应用于单个项目时,它似乎无法与运费表一起正常工作。装运规则似乎优先,并根据购物车总数进行计算 诀窍是在运费模块进行计算时,从购物车总额中减去免费送货项目 在我的例子中,某个特定类别(id:15)内的所有内容都是免费发货。但您可以修改逻辑以满足您的需要 您需要修改以下文件(或将其复制到本地代码库以正确执行操作) app\code\core\Mage\Shipping\Model\Carrier\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());
}
}
}
为此:
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());
}
}
}
我知道这个问题已经得到了回答和接受,但我想提供一种方法来做到这一点,而无需编程,或者在可能的情况下更改核心文件 如果要将项目创建为“虚拟”项目,可以从运费中排除虚拟项目 如果项目已创建 使用类似phpMyAdmin的程序访问数据库,导航到
目录\u产品\u实体
,找到产品SKU并将类型\u id
更改为虚拟
如果未创建项目
在产品创建的第一步中将项目创建为虚拟产品
(而不是简单产品
或捆绑产品
等)
从运费中排除虚拟产品
导航到System>Configuration>Shipping Methods
,并在表格Rates
标题下设置在价格计算中包含虚拟产品
至否
- 请注意,这仅适用于且仅适用于
装运方法表费率
- UPS、USPS、联邦快递和DHL按重量确定,因此,由于虚拟产品类型的产品重量为0,因此不会影响这些方法的运输成本