| 1234567891011121314151617181920212223242526272829303132 |
- import json
- import db
- import config
- def on_order_created(order_id: int):
- """
- Hook triggered asynchronously when a new order is placed.
- Users can add any notification logic here (e.g. email or telegram).
- """
- print(f"EVENT: Order {order_id} created.")
- # Fetch order data if needed
- order = db.execute_query("SELECT * FROM orders WHERE id = %s", (order_id,))
- if order:
- order_data = order[0]
- # TODO: Add your notification logic here
- pass
- def on_order_status_changed(order_id: int, status: str, order_data: dict, send_notification: bool):
- """
- Hook triggered asynchronously when the admin changes the order status.
- Uses the send_notification flag explicitly.
- """
- print(f"EVENT: Order {order_id} status changed to {status}. Notify user: {send_notification}")
-
- if send_notification:
- # TODO: Add your notification logic here (Email, Telegram, SMS, etc.)
- # The order_data dictionary contains all the details of the order.
- user_email = order_data.get('email')
- first_name = order_data.get('first_name')
-
- print(f"--> Sending notification to {user_email} (User: {first_name})...")
- pass
|