5

我可以使用 Magento 实现以下目标:

我正在使用价格与目的地的表格费率系统。对于具有属性 free_shipping -> 设置为“是”的产品,我有一个免费送货的购物车价格规则。

如果您在篮子里有普通产品或在篮子里有免费送货产品,这很好用。但是,如果您的购物篮中既有普通产品又有免费送货产品。它根据订单总额计算运费,包括免费送货的产品。

我该如何更正这一点,因此当购物篮中同时存在两种类型的产品时,运费仅适用于不包括免费送货的产品订单总额?

有Magento插件吗?提前致谢。

4

4 回答 4

2

在您的销售规则中,将免费送货设置为“仅限匹配项”。

于 2011-07-01T10:09:16.297 回答
2

我遇到了同样的问题并实施了一个小的代码更改以使其工作。

基本上忘记了促销规则。禁用它。对单个商品应用免费送货时,运费表似乎无法正常工作。运输规则似乎优先并根据购物车总数计算。

诀窍是在运费模块进行计算时从购物车总数中减去免费送货项目。

就我而言,特定类别(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());
                }
        }
    }
于 2012-02-20T13:04:07.010 回答
1

如果我正确理解了您的问题,则解决方案非常简单快捷,以下是我的解决方法:

在文件中:Validator.php (/app/code/core/Mage/SalesRule/Model/) 搜索字符串“case Mage_SalesRule_Model_Rule::FREE_SHIPPING_ITEM:”,就在“break;”之前 添加这个简单的东西“$item->setWeight(0);”

这将强制商品的重量为 0,因此不会计算运费,如果您禁用帽子商品的免费送货选项,则会考虑重量并且一切正常。

于 2011-07-08T14:19:59.967 回答
0

我知道这个问题已经得到回答和接受,但我想提供一种无需编程或更改核心文件(如果可能的话)的方法

如果您想将您的商品创建为“虚拟”商品,您可以将虚拟商品从运费中排除

如果项目已经创建

使用 phpMyAdmin 之类的程序转到您的数据库并导航到catalog_product_entity,找到您的产品 SKU 并更改type_idvirtual

如果未创建项目

Virtual Product在产品创建的第一步中创建项目(而不是Simple ProductorBundled Product等​​)

Virtual Products从运费中排除

导航到设置为No的标题System > Configuration > Shipping Methods并在其下方Table RatesInclude Virtual Products in Price Calculation

  • 请注意,这仅适用于并且仅适用于Table Rates运输方式
  • UPS、USPS、FedEx 和 DHL 按重量确定,因此由于虚拟产品类型的产品重量为 0,因此不会影响这些方法的运费
于 2015-03-20T14:10:24.443 回答