Shopper\Core\Eventsorder and product eventsShopper\Cart\Eventscart events
Listening to Events
Register listeners in your application’sEventServiceProvider or use Laravel’s event discovery:
Order Events
Order events cover the full lifecycle of a purchase, from creation to completion, cancellation, or archival.Available Events
All order events carry a single
public Order $order property.
Lifecycle Flow
How They Are Dispatched
OrderCreated and OrderDeleted are dispatched automatically via the model observer. They fire on every insert and soft-delete, regardless of where the operation originates.
OrderPaid, OrderCompleted, OrderCancelled, OrderArchived) are dispatched from the admin panel when an administrator changes the order status.
OrderShipped is dispatched by SyncOrderShippingStatusAction when the aggregated shipping status of all items transitions to Shipped. This happens automatically after shipment events are recorded, so you don’t dispatch it manually.
Queueing
All order events implementShouldDispatchAfterCommit, meaning listeners run on the queue after the database transaction commits.
Shipment Events
Shipment events track the creation and delivery of individual packages within an order. A single order can have multiple shipments.Available Events
Both shipment events carry two properties: the order and the specific shipment. This is useful when an order has multiple packages and you need to know which one was created or delivered.
Shipment vs Order Events
Shipment events fire at the package level, order events fire at the order level:Product Events
Product events are dispatched when products are created, updated, or deleted through the admin panel.Available Events
All product events implement
ShouldDispatchAfterCommit, so listeners run on the queue after the database transaction commits.Example: Order Notification System
Here’s how you might use Shopper events to build a notification flow for your store. Each listener handles a single responsibility. Register your listeners:Cart Events
Cart events are dispatched when a cart reaches a key state during the checkout process.Available Events
Cart events are in the
Shopper\Cart\Events namespace: