I have a Django app called receipt_printer which should be printing an order when it is received using a signal. There are two apps here called: Orders and receipt_printer.
However, whenever an order is processed and fully charged I can't get the signals to work. The example below just prints out something to the console for simplicity. If I do everything inside the models.py in the Orders app it works fine.
receipt_printer/apps.py
from django.apps import AppConfig
class ReceiptPrinterConfig(AppConfig):
name = 'receipt_printer'
def ready(self):
from . import signals
receipt_printer/signals.py
from django.db import models
from saleor.order.models import Order
from django.db.models.signals import post_save
def order_fully_paid_signal(sender, instance, created, **kwargs):
if instance.get_payment_status() == "fully-charged":
print("This signal is working for fully paid order")
else:
print("This signal won't working for fully paid order")
post_save.connect(order_fully_paid_signal, sender=Order)
receipt_printer/init.py
default_app_config = 'receipt_printer.apps.ReceiptPrinterConfig'
UPDATE, also tried the below - didn't work:
@receiver(post_save, sender=Order)
def order_fully_paid_signal(sender, instance, created, **kwargs):
if instance.get_payment_status() == "fully-charged":
print("This signal is working for fully paid order")
else:
print("This signal won't working for fully paid order")
I needed to add the following line to the bottom of my models.py for the Orders app:
from saleor.saleor_package.receipt_printer.signals import order_fully_paid_signal