Version: 2.11

Events

Key concepts

Events are auto-generated and are triggered when certain actions are completed; for example, creating an order, cancelling fulfillment or completing a payment.

Architecture

Each package representing an entity (order, account, etc.) that generates events defines both a model and an events.py file containing a set of functions with an _event as a suffix.

Those functions take care of any logic and the required fields for creating given events.

Creating events

To send an event, run the following code:

from saleor.order import events
# returns an OrderEvent
events.note_added_event(order=order, user=user, message="hello world!")

If you want to send a sent email event, run the following code:

from saleor.order import events
events.email_sent_event(
order=order,
user=user,
email_type=events.OrderEventsEmails.TRACKING_UPDATED,
)

Take note of the way the email type is provided.

note

The methods are using a model_action_event naming pattern.

Order events

CodeGraphQL API ValueDescriptionAdditional Parameters (GraphQL)
draft_createdDRAFT_CREATEDA draft order was created by a staff userNone
draft_added_productsDRAFT_ADDED_PRODUCTSA staff user added products to a draft orderlines a list of objects containing a quantity (int), a line_pk (int) and a item_name (string)
draft_removed_productsDRAFT_REMOVED_PRODUCTSThe staff user removed products from a draft orderlines a list of objects containing a quantity (int), a line_pk (int) and a item_name (string)
placedPLACEDAn order was placed by a customerNone
draft_placedPLACED_FROM_DRAFTAn order was created from draft by the staff userNone
oversold_itemsOVERSOLD_ITEMSThe order was created from draft, but some line items were oversoldoversold_items a list of items (strings)
canceledCANCELEDThe order was cancelledNone
order_paidORDER_PAIDThe order was fully paid by the customeramount (float), payment_id (string), payment_gateway (string)
marked_as_paidMARKED_AS_PAIDThe order was manually marked as fully paid by the staff userNone
email_sentEMAIL_SENTAn email was sent to the customeremail (string), email_type (OrderEventsEmailsEnum)
capturedCAPTUREDThe payment was capturedamount (float), payment_id (string), payment_gateway (string)
refundedREFUNDEDThe payment was refundedamount (float), payment_id (string), payment_gateway (string)
voidedVOIDEDThe payment was voidedamount (float), payment_id (string), payment_gateway (string)
payment_failedPAYMENT_FAILEDThe payment failedmessage (string), payment_id (string, optional), payment_gateway (string, optional)
fulfillment_canceledFULFILLMENT_CANCELEDFulfillment for one or more of the items was canceledcomposed_id (int)
restocked_itemsRESTOCKED_ITEMSOne or more of the order’s items was restockedquantity (int)
fulfilled_itemsFULFILLED_ITEMSOne or more of the order’s items was fulfilledfulfilled_items a list of line_pk (int)
note_addedNOTE_ADDEDA note was added to the order by a staff membermessage (string)
otherOTHERStatus used during re-importing of legacy eventsNone

Communication events

CodeGraphQL API ValueDescription
payment_confirmationPAYMENTThe order was fully paid
shipping_confirmationSHIPPINGThe order was shipped
tracking_updatedTRACKING_UPDATEDThe shipping tracking number was updated
order_confirmationORDERThe order was placed
fulfillment_confirmationFULFILLMENTOne or more of the order’s items was fulfilled (either physical or digital)
digital_linksDIGITAL_LINKSThe links to the order’s digital goods were sent

Customer events

CodeGraphQL API ValueDescriptionAdditional Parameters (GraphQL)
account_createdACCOUNT_CREATEDThe customer’s account was createdNone
password_reset_link_sentPASSWORD_RESET_LINK_SENTThe password reset email was sentNone
password_resetPASSWORD_RESETThe customer reset (changed) their passwordNone
placed_orderPLACED_ORDERThe customer placed an orderNone
note_added_to_orderNOTE_ADDED_TO_ORDERThe customer added a note to one of their ordersmessage (string) the message that the customer put as a note
digital_link_downloadedDIGITAL_LINK_DOWNLOADEDThe customer or another user (anonymous) downloaded an ordered digital goodorder_line (OrderLine) the fulfilled digital order line that the user downloaded
customer_deletedCUSTOMER_DELETEDThe staff user deleted one or more customers (anonymous)count (int) the amount of customers deleted by the user
email_assignedEMAIL_ASSIGNEDThe staff user assigned a new email address to a customermessage (string) the assigned email address
name_assignedNAME_ASSIGNEDThe staff user assigned a new full name to a customermessage (string) the assigned full name
note_addedNOTE_ADDEDThe staff user added a note to a customermessage (string) the note added to the customer