Django Oscar - email admin on order placed

后端 未结 1 1891
暗喜
暗喜 2021-01-16 22:57

I am trying to get django-oscar to send me an email everytime an order is placed. It sounds simple but I am struggling.

I have tried a couple of methods but all fai

1条回答
  •  再見小時候
    2021-01-16 23:20

    You can set up a listener for the order_placed signal, and then do whatever actions you want there.

    from django.dispatch import receiver
    
    from oscar.apps.order.signals import order_placed
    
    @receiver(order_placed)
    def send_merchant_notification(sender, order, user, **kwargs):
        # Do stuff here
    

    Alternatively, fork the orders app and override the OrderCreator class to inject additional logic when an order is placed.

    0 讨论(0)
提交回复
热议问题