以编程方式为客人设置 magento 税率 ID 的正确方法是什么

发布于 2024-09-26 12:03:15 字数 113 浏览 1 评论 0原文

我正在尝试根据优惠券代码为客人(未登录)设置税率。

我已经尝试了我能想到的每一个单例,但即使手动设置我想要设置的 customertaxrateid 也遇到了麻烦。

有什么想法吗?

i am trying to set a tax rate for a guest (not logged in) based on a coupon code.

i have tried every singleton i can think of and am having trouble even manually setting the customertaxrateid that i would like to set.

any ideas?

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

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

发布评论

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

评论(1

转身泪倾城 2024-10-03 12:03:15

所以更新并回答...我在放置代码时犯了一个非常愚蠢的错误,但在发现网络上完全缺乏有关这些主题的信息后...我想我会分享一些代码...评论而不是我的自定义解决方案我正在使用...但它有效!

代码需要添加到:
/app/code/core/Mage/Tax/Model/Calculation.php

$couponCode = Mage::getSingleton('checkout/cart')->getQuote()->getCouponCode();
if (!empty($couponCode)) {

    $db = Mage::getSingleton('core/resource')->getConnection('core_read');
    $query = ""//put your sql query here since magento makes it hard to respect MVC when a group of setters and getters think you are running mysql4 even though you are using mysql5
            $result = $db->query($query);

    while ($row = $result->fetch() ) {
        //lazy method to avoid the need for more error handling                 
        $customerTaxClass = $row['class_id'];
    }

}

应该在 getRateRequest 函数创建要返回的 $request 之前完成。

so update and answer... i made a really stupid mistake placing my code but after finding a complete lack of information about these subjects on the web... i thought i would share some code... commented instead of the custom solution i am using... but it works!!!

the code needs to be added in:
/app/code/core/Mage/Tax/Model/Calculation.php

$couponCode = Mage::getSingleton('checkout/cart')->getQuote()->getCouponCode();
if (!empty($couponCode)) {

    $db = Mage::getSingleton('core/resource')->getConnection('core_read');
    $query = ""//put your sql query here since magento makes it hard to respect MVC when a group of setters and getters think you are running mysql4 even though you are using mysql5
            $result = $db->query($query);

    while ($row = $result->fetch() ) {
        //lazy method to avoid the need for more error handling                 
        $customerTaxClass = $row['class_id'];
    }

}

it should be done in the getRateRequest function before it creates the $request to return.

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