django oscar:如何向商店管理员发送电子邮件以进行订单放置通知 [英] django oscar: How to send an email to store admin for order placement notification

查看:49
本文介绍了django oscar:如何向商店管理员发送电子邮件以进行订单放置通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想收到通知

电子邮件

当我的django-oscar商店有新订单时,

对我自己(作为管理员).

to myself (As Admin) when there is new order placed on my django-oscar store.

推荐答案

我遵循的一种方式是向管理员发送电子邮件,我所做的是将订单应用程序分叉并转到utils.py,到OrderCreator()类下的place_order函数,oscar发送信号以进行订单放置,来自oscar的github的代码是

There is a way that I am following to send emails to the admins, what I did was forked the order app and the went to the utils.py, went to the place_order function under OrderCreator() class, oscar sends signals for order placement the code from oscar's github is here, so what I did was put my send email code after this. SO I created a communication event type with code ADMIN_ORDER_MAIL in my admin side and used that here to send mails.

我的代码在这里:

# Send an email to admin on placing of order
        ctx = {'order': order, 'user': order.user}
        commtype_code = 'ADMIN_ORDER_MAIL'
        try:
            event_type = CommunicationEventType.objects.get(code=commtype_code)
            # print("Event type typr: ", type(event_type))
            # self.create_communication_event(order, event_type)

        except Exception as e:
            messages = CommunicationEventType.objects.get_and_render(code=commtype_code, context=ctx)
            # print(e)
        else:
            messages = event_type.get_messages(ctx)

            send_mail(
                subject=messages['subject'],
                message='',
                html_message=messages['html'],
                from_email='from email address',
                recipient_list=['to email address'],
                fail_silently=False,
            )

这篇关于django oscar:如何向商店管理员发送电子邮件以进行订单放置通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆