萨奇莫礼券。购买多张礼券但仅收到一个代码
因此,我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我远非该领域的专家,也没有与听众打交道的经验...但我想说,听众只被调用一次,因为表单也只被发布/保存一次。因此,也许您应该查找在模型实例上购买的优惠券数量,然后从那里继续发送多封邮件...或者购买的优惠券数量可能反映了您被允许使用优惠券/代码的次数?
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?