Magento 从购物车中删除商品/删除报价操作不完整 - 价格规则错误

发布于 2024-10-16 02:39:04 字数 600 浏览 4 评论 0原文

有人注意到引用没有被正确删除吗? 例如,优惠券代码变量在您从购物车中删除产品后保留该值。

尝试:

1.为产品设置一些购物车价格规则,并使其在标题部分显示横幅。

2. 将产品[仅此产品]添加到结帐/购物车,以触发规则并在结帐/购物车上显示横幅。

3。从购物车中删除产品,您将看到横幅仍显示在标题部分。

笔记。如果您的购物车中有其他产品,则此操作将不起作用,因为当您删除触发规则和横幅的产品时,优惠券代码将被属于购物车中其他产品的代码替换。 因此,只有当购物车中只有触发规则和横幅的产品时,此错误才会起作用。

如果有人解决了这个问题或者可以复制这些条件:我很乐意就 magento 的缺陷进行对话,以便从购物车中删除适当的产品 - 这意味着适当的报价刷新。

- code/core/Mage/Sales/Model/Quote.php -> public function removeItem($itemId)

在 Magento 企业版上找到

Did anybody notice that the quote is not being deleted properly?
For example the coupon code variable keeps the value after you delete a product from cart.

Try:

1. Set some Shopping Price Cart Rule to a product and make it display a banner on the header section.

2. Add the product [only this product] to checkout/cart in order to trigger the rule and show the banner on the checkout/cart.

3. Delete the product from cart and you will see the banner still showing on the header section.

Note. If you have another product in cart this will not work because when you delete the one that triggered the rule&banner the Coupon Code will get replaced with the one that belongs to this other product in cart.
SO this bug only works if only the product that triggers the rule&banner is in cart.

If anybody has a fix on this or can replicate these conditions: I'd love to have a conversation about magento's deficiency to make a proper product delete from cart - which implies a proper quote refresh.

- code/core/Mage/Sales/Model/Quote.php -> public function removeItem($itemId)

Found on Magento Enterprise Edition

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

草莓味的萝莉 2024-10-23 02:39:04

您可以使用 sales_quote_remove_item 事件来修复它。

1)创建新扩展(这里是如何做到这一点的好答案:如何在 Magento 中创建 Hello world 扩展?)并将下一部分添加到您的 config.xml 中:

<events>
    <sales_quote_remove_item>
        <observers>
            <sales_quote_remove_item_handler>
                <type>singleton</type>
                <class>Your_Extension_Model_Observer</class>
                <method>unsetCouponCode</method>
            </sales_quote_remove_item_handler>
        </observers>
    </sales_quote_remove_item>
</events>

2)创建文件 app/code/local/Your/Extension/Model/Observer.php :

<?php
class Your_Extension_Model_Observer {

    public function unsetCouponCode(Varien_Event_Observer $observer) {
        $quote = $observer->getQuoteItem()->getQuote();
        if (!$quote->hasItems()) {
            Mage::getSingleton('core/session')->setCouponCode('');
            $quote->getShippingAddress()->setCollectShippingRates(true);
            $quote->setCouponCode('')->collectTotals()->save();
        }
    }
}

之后清除 Magento缓存并尝试重复问题 - 它应该消失。

You can use sales_quote_remove_item event for fixing it.

1) Create new extension (here is good answer how to do it: How to create a Hello world extension in Magento?) and add next section to your config.xml:

<events>
    <sales_quote_remove_item>
        <observers>
            <sales_quote_remove_item_handler>
                <type>singleton</type>
                <class>Your_Extension_Model_Observer</class>
                <method>unsetCouponCode</method>
            </sales_quote_remove_item_handler>
        </observers>
    </sales_quote_remove_item>
</events>

2) Create file app/code/local/Your/Extension/Model/Observer.php :

<?php
class Your_Extension_Model_Observer {

    public function unsetCouponCode(Varien_Event_Observer $observer) {
        $quote = $observer->getQuoteItem()->getQuote();
        if (!$quote->hasItems()) {
            Mage::getSingleton('core/session')->setCouponCode('');
            $quote->getShippingAddress()->setCollectShippingRates(true);
            $quote->setCouponCode('')->collectTotals()->save();
        }
    }
}

After that clear Magento cache and try to repeat issue - it should gone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文