2

我正在尝试将购物车价格规则应用于捆绑产品,但没有成功。我想要做的是,创建一个优惠券代码,在 SKU 'ABC' 的捆绑产品上应用 10% 的折扣。

因此,我将 SKU 属性设置为“用于促销规则条件”->“是”,然后创建如下规则:

If ALL  of these conditions are TRUE :
If an item is FOUND  in the cart with ANY  of these conditions true: 
SKU is ABC

但没有成功...

所以我阅读了一些关于捆绑产品和价格规则仅适用于简单产品的内容(是这样吗?),所以我改变了我的规则,使其适用于我的捆绑产品中的产品:

If ALL  of these conditions are TRUE :
If an item is FOUND  in the cart with ANY  of these conditions true: 
SKU is one of ABC,ABC-1,ABC-2

没运气...

因此,我尝试保留整个 SKU 事物,并创建一个新属性:give_discount,并将其也设置为“用于促销规则条件”->“是”。是的,此时此刻我是那么绝望。我创建属性,将其添加到我的捆绑包以及它的子产品中:

If ALL  of these conditions are TRUE :
If an item is FOUND  in the cart with ANY  of these conditions true: 
Give discount  is  Yes 

还是……不……运气……

现在,有人知道这里发生了什么吗?我只是无法绕过它!像这样,同装商品不可能打折吗?当我离开条件时,会给出折扣(如预期的那样),但是一旦我应用过滤器,我就会得到优惠券代码无效的概念......

编辑:

我的价格规则适用于其他类型的产品。经过一番研究,我设法通过创建一个隐藏类别、将捆绑产品放入其中并将价格规则应用于该类别来使代码正常工作。这是实现上述目标的唯一方法吗?

4

2 回答 2

1

试试这个:

条件:

If ALL  of these conditions are TRUE :
    If an item is FOUND  in the cart with ALL  of these conditions true: 
        SKU  is  ABC  

    If an item is FOUND  in the cart with ALL  of these conditions true: 
        SKU  is  ABC-1

    If an item is FOUND  in the cart with ALL  of these conditions true: 
        SKU  is  ABC-2  

行动:

Update prices using the following information
    Apply: Fixed Amount discount
    Discount amount : 10%
    Maximum Qty Discount is Applied to: 1
    Discount Qty Step (Buy X): 0
    Apply to Shipping Amount: No
    Free shipping: No
    Stop further rules processing: No

Apply the rule only to cart items matching the following conditions (leave blank for all items)
    If ALL  of these conditions are TRUE :
        SKU  is  ABC  
        SKU  is  ABC-1
        SKU  is  ABC-2 
于 2014-07-22T14:45:23.377 回答
0

我有同样的问题。当您将产品与一个虚拟孩子捆绑在一起时,就会发生这种情况。

我有修复它:

创建新模块目录 app/code/MyCompany/MyModule/

这个目录中的下一个文件:

等/模块.xml

    <?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="MyCompany_MyModule" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Quote"/>
        </sequence>
    </module>
</config>

等/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

    <preference for="Magento\Quote\Model\Quote\Item" type="MyCompany\MyModule\Model\Quote\Item"/>

</config>

作曲家.json

{
  "name": "my-company/my-module",
  "description": "N/A",
  "require": {
    "php": "~7.0.0"
  },
  "type": "magento2-module",
  "version": "1.0.0",
  "license": "proprietary",
  "autoload": {
    "files": [
      "registration.php"
    ],
    "psr-4": {
      "MyCompany\\MyModule\\": ""
    }
  }
}

注册.json

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'MyCompany_MyModule',
    __DIR__
);

型号/报价/Item.php

<?php
namespace MyCompany\MyModule\Model\Quote;

class Item extends \Magento\Quote\Model\Quote\Item
{

    /**
     * @return \Magento\Quote\Model\Quote\Address
     */
    public function getAddress()
    {
        /** start @override code */
        if ($this->getQuote()->isVirtual()) {
            /** end @override code */
            $address = $this->getQuote()->getBillingAddress();
        } else {
            $address = $this->getQuote()->getShippingAddress();
        }

        return $address;
    }
}
于 2019-05-23T10:48:21.167 回答