Events¶
Events are the core concept in this plugin. Each event maps a WooCommerce/WordPress action to a Klaviyo metric or profile update.
Supported events¶
Order events¶
| Event class | Klaviyo metric |
|---|---|
OrderPlacedEvent | Placed Order |
OrderRefundedEvent | Refunded Order |
OrderReturnFlow | Return Flow |
Subscription events¶
| Event class | Klaviyo metric |
|---|---|
SubscriptionCreatedEvent | Subscription Created |
SubscriptionActivatedEvent | Subscription Activated |
SubscriptionCancelledEvent | Subscription Cancelled |
SubscriptionPausedEvent | Subscription Paused |
SubscriptionPauseExtendedEvent | Subscription Pause Extended |
SubscriptionPendingCancelEvent | Subscription Pending Cancel |
SubscriptionStopFlowEvent | Stop Flow |
SubscriptionOffboardingDiscountAdded | Offboarding Discount Added |
SubscriptionTmpOnholdEndingNotificationEvent | Onhold Ending Notification |
SubscriptionUpdatedIdentify | Profile identify (subscription data) |
User / account events¶
| Event class | Klaviyo metric |
|---|---|
AccountCreatedEvent | Account Created |
UserUpdatedIdentify | Profile identify (user data) |
UserRequestResetPasswordEvent | User Request Reset Password |
DAO / logistics¶
| Event class | Klaviyo metric |
|---|---|
DaoReturnLabelCreated | Return Label Created |
Event registry¶
All events are registered via EventRegistry (inc/Events/EventRegistry.php). New events must be added there to be schedulable.
Adding a custom event¶
- Create a class in
inc/Events/Events/that extendsBaseEvent(orBaseOrderEvent/BaseSubscriptionEvent). - Implement
EventInterface. - Register it in
EventRegistry. - Add a watcher in
inc/Watchers/that callsEventSchedulerAPI::schedule()on the relevant WC/WP hook.
Forced events¶
By default, the UNIQUE KEY (event_code, entity_id) prevents the same event from being queued twice for the same entity. Set $scheduledEvent->set_forced(true) to bypass deduplication — the existing row is deleted and replaced. This is useful for recurring status changes (e.g. chargebacks).
Hooks from base-plugin (>= 2.7.0)¶
base-plugin no longer calls this package directly. It fires actions and we listen:
| base-plugin action | Listener | Event scheduled |
|---|---|---|
flow-checkout/subscription/parent-order (WC_Order, WC_Subscription) | Watchers\Orders::on_flow_checkout_parent_order | PENDING_ORDER |
base-plugin/subscription/addon-product/item-deleted (WC_Subscription, SubscriptionItemAddon) | Watchers\PluginsEventAPIProvisioner::subscription_addons__item_deleted | SUBSCRIPTION_UPDATED with the addon disabled |
flow-checkout/subscription/marketing-permissions (WC_Subscription, ?string $context) | Trackers\CheckoutTracking::on_marketing_permissions | none; adds the marketing consent synchronously |
This package requires base-plugin ^2.7, and base-plugin 2.7+ conflicts with this package < 3.2.0, so the two are always upgraded together.