将 [magento] 优惠券代码限制为特定客户列表?

发布于 2024-12-21 15:51:01 字数 268 浏览 0 评论 0原文

关于如何限制特定客户列表使用优惠券代码有什么想法吗?

背景:我的公司正在进行促销活动,我们已经通过电子邮件向 2000 多个高价值客户列表发送了折扣代码。我们不希望所有客户都能够使用该代码,而只是我们列表中的客户。问题是优惠券代码已经发布在一些流行的论坛和其他地方,所以除非我们采取措施阻止它,否则我们会收到一堆不打算获取代码的人的订单。

我正在尝试进行一些紧急损害控制 - 我想我必须在某个地方进行代码修改,但我仍在环顾四周,无法找出最佳位置。我的文件中有一份客户列表。

Any ideas on how to restrict the coupon code to be used by a specific list of customers?

Background: My company is doing a promo, and we already emailed a discount code out to a list of 2000+ highly valuable customers. We don't want ALL of our customers to be able to use the code, just the ones in our list. And the problem is that the coupon code has already been posted on some popular forums, and other places, so unless we do something to prevent it, we'll get a bunch of orders from folks that weren't intended to get the code.

I am trying to do some emergency damage control - I figure I am gonna have to make a code modification somewhere, but I am still looking around, can't figure out the best place. I have a list of customers in a file.

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

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

发布评论

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

评论(3

謸气贵蔟 2024-12-28 15:51:01

您可以创建一个观察者来观察 salesrule_validator_process(应用购物车规则时会触发此事件),该观察者必须检查两件事:

  • 应用的规则是您想要限制给客户的规则列表:

    $ruleId = $observer->getEvent()->getRule()->getRuleId();
    
  • 如果满足第一个条件,则检查客户是否已登录,并且电子邮件是其中的电子邮件之一您的列表:

    if ($observer->getEvent()->getQuote()->getCustomer()->getEmail()) {
        $customerEmail = $observer->getEvent()->getQuote()->getCustomer()->getEmail();
        if ($customerEmail 在您的列表中) {
            返回$这个;
        } 别的 {
            $event = $observer->getEvent();
            $result = $event->getResult();
            $结果->setBaseDiscountAmount(0)->setDiscountAmount(0);
    } 别的 {
        $event = $observer->getEvent();
        $result = $event->getResult();
        $结果->setBaseDiscountAmount(0)->setDiscountAmount(0);
    }
    

您应该重构此代码以使其干燥,而且我还没有不做一个实际的 if 条件,但你明白了。
此外,您还必须更改消息“优惠券已成功应用”。
告诉我您是否需要更多详细信息。

You could create an observer observing salesrule_validator_process (this event is triggered when a shopping cart rule is applied) which would have to check 2 things:

  • the rule applied is the rule you wanna restrict to your customers list:

    $ruleId = $observer->getEvent()->getRule()->getRuleId();
    
  • if the first condition is met, then check that the customer is logged in and that is email is one of the emails in your list:

    if ($observer->getEvent()->getQuote()->getCustomer()->getEmail()) {
        $customerEmail = $observer->getEvent()->getQuote()->getCustomer()->getEmail();
        if ($customerEmail IS ON YOUR LIST) {
            return $this;
        } else {
            $event = $observer->getEvent();
            $result = $event->getResult();
            $result->setBaseDiscountAmount(0)->setDiscountAmount(0);
    } else {
        $event = $observer->getEvent();
        $result = $event->getResult();
        $result->setBaseDiscountAmount(0)->setDiscountAmount(0);
    }
    

you should refactor this code to queep it DRY, and also I haven't make an actual if condition, but you get the picture.
also you'll have to change the message "coupon has been succesfully applied".
tell me if you need more details.

混吃等死 2024-12-28 15:51:01

Sdek 你可以像 Osdave 解释的那样创建观察者。或者,如果您有已收到促销代码和信息的客户列表你不愿意让他们使用那个促销。
您可以执行以下操作

  1. 准备列表(电子邮件)
  2. 创建客户组 NO-promo-Customer
  3. 准备一个脚本,可能是一个 SQL 查询,将您列表中的用户客户组更新为 No-promo-customer
  4. 转到该促销规则你已经创造了。编辑它。 &在客户组部分下选择No-promo-Customer

这应该可以满足您想要完成的任务。

Sdek u can create the oberver like Osdave explained. Or if u have a list of customers who have received the Promo code & ur not willing to let them use that promo.
u can do as follows

  1. Prepare the list (emails)
  2. Create a Customer Group NO-promo-Customer
  3. prepare a script may be an SQL query that updates the Customer Group of users in ur list to No-promo-customer
  4. Go to that promo Rule that u have created. edit it. & Under section Customer Groups choose No-promo-Customer

This should fulfill what ur trying to accomplish.

ぇ气 2024-12-28 15:51:01

也许您可以使用客户折扣

Perhaps you could use customer discounts

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