萨奇莫礼券。购买多张礼券但仅收到一个代码

发布于 2024-11-04 17:38:55 字数 925 浏览 1 评论 0原文

因此,我正在使用 Satchmo Store,并且设置了一个礼券模块作为在我的网站上购买优惠券的方式。但是,当我在选择数量页面上购买超过 1 个时,它只会向我发送一张礼券,而不是根据我购买的数量发送多张礼券。

这是购买后如何通过电子邮件发送礼券的监听器。有人对此有一些见解吗?

def coupon_notify(sender, instance, created, **kwargs):
    recipient = instance.purchased_by.email
    buyer = '%s %s' % (instance.purchased_by.first_name, instance.purchased_by.last_name)
    subject = "You Coupon"
    html_content = 'Your code:<br><strong style="font-size:40px; color:#000;">%s</strong>' % (instance.code)
    sender = '[email protected]'
    msg = EmailMessage(subject, html_content, sender, [recipient])
    msg.content_subtype = "html"
    msg.send()


def coupon_code_listener():
    save_signals.post_save.connect(coupon_notify,\
        sender=GiftCertificate,dispatch_uid="coupon_notify")

So I am using Satchmo Store and I have a gift certificate module set up as a way to purchase coupons on my website. However, when I purchase more than 1 on the select quantity page it will only email me one Gift Certificate, not multiple ones according to how many I purchased.

Here is the listener to how the gift certificate is emailed once purchased. Any one have some insight to this?

def coupon_notify(sender, instance, created, **kwargs):
    recipient = instance.purchased_by.email
    buyer = '%s %s' % (instance.purchased_by.first_name, instance.purchased_by.last_name)
    subject = "You Coupon"
    html_content = 'Your code:<br><strong style="font-size:40px; color:#000;">%s</strong>' % (instance.code)
    sender = '[email protected]'
    msg = EmailMessage(subject, html_content, sender, [recipient])
    msg.content_subtype = "html"
    msg.send()


def coupon_code_listener():
    save_signals.post_save.connect(coupon_notify,\
        sender=GiftCertificate,dispatch_uid="coupon_notify")

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

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

发布评论

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

评论(1

风吹过旳痕迹 2024-11-11 17:38:55

我远非该领域的专家,也没有与听众打交道的经验...但我想说,听众只被调用一次,因为表单也只被发布/保存一次。因此,也许您应该查找在模型实例上购买的优惠券数量,然后从那里继续发送多封邮件...或者购买的优惠券数量可能反映了您被允许使用优惠券/代码的次数?

i'm far from an expert on the field and have no experience with listeners... but I would say that the listener is called only once because the form is posted/saved only once too. So maybe you should look for the amount of coupons purchased on the model-instance and then go on from there to send multiple mails... or maybe the amount of coupons purchased reflect on how many times you are allowed to use the coupon/code?

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