This section is intended for developers who want to extend or customize the plugin. The hook names and argument lists below are confirmed against the current source code (pre-release API).
13.1 Action Hooks
wprr_sfwco_notification_queued
When it runs: After a notification has been successfully queued and its log record retrieved.
Arguments: $notification (The notification metadata object from the plugin's log).
Purpose: Perform an additional task when a notification is queued.
add_action( 'wprr_sfwco_notification_queued', function( $notification ) {
// Custom logging or auditing logic
}, 10, 1 );
wprr_sfwco_before_notification_send
When it runs: Immediately before the plugin makes its Slack HTTP request.
Arguments: $notification (object), $order (WC_Order), $payload (array).
Purpose: Observe or inspect the notification before the request is dispatched.
add_action( 'wprr_sfwco_before_notification_send', function( $notification, $order, $payload ) {
// Inspect outgoing payload or order context
}, 10, 3 );
wprr_sfwco_notification_sent
When it runs: After the plugin receives a successful HTTP response and updates the record to sent.
Arguments: $notification (object), $order (WC_Order).
Purpose: Perform an additional task after successful HTTP delivery.
add_action( 'wprr_sfwco_notification_sent', function( $notification, $order ) {
// Notification delivered successfully to Slack
}, 10, 2 );
Important: This action indicates a successful HTTP response. It should not be interpreted as proof that a person read the message.
wprr_sfwco_notification_failed
When it runs: When the plugin marks a notification as failed after an exhausted or non-retryable delivery failure, or when it encounters an invalid webhook URL during delivery.
Arguments: $notification (object), $sanitized_error (string).
Purpose: Perform additional monitoring, error logging, or alerting when delivery fails.
add_action( 'wprr_sfwco_notification_failed', function( $notification, $sanitized_error ) {
// Send administrative email or log to monitoring service
}, 10, 2 );
wprr_sfwco_manual_retry_requested
When it runs: When an administrator requests a retry for an eligible failed notification in WordPress admin.
Arguments: $notification (The notification metadata object retrieved before the retry state is reset).
Purpose: Observe manual retry requests for auditing purposes.
add_action( 'wprr_sfwco_manual_retry_requested', function( $notification ) {
// Audit manual retry action
}, 10, 1 );
13.2 Important Notes About Action Hooks
- The notification metadata object is a database record object, not a complete rendered Slack message.
- The hooks are intended for lightweight extension tasks. Callbacks should not throw exceptions, perform slow operations, or interrupt WooCommerce checkout and order processing.
- The plugin wraps its extension action calls in exception-handling logic. However, developers should not rely on that behavior as a substitute for writing safe callbacks.
- Do not expose customer information, webhook URLs, or other sensitive values in logs or external monitoring systems unless explicitly authorized.
13.3 Filter Hooks
wprr_sfwco_notification_values
Purpose: Modify the placeholder-value array before the message template is rendered.
Arguments: $values (array), $event_type (string), $order (WC_Order), $notification (object).
Return Value: An array of placeholder values. Custom placeholders added to this array can be used in templates, provided the value is scalar.
add_filter( 'wprr_sfwco_notification_values', function( $values, $event_type, $order, $notification ) {
// Add custom placeholder {delivery_zone}
$values['{delivery_zone}'] = get_post_meta( $order->get_id(), '_delivery_zone', true ) ?: 'Standard';
return $values;
}, 10, 4 );
wprr_sfwco_notification_message
Purpose: Modify the fully rendered notification message string before payload assembly.
Arguments: $message (string), $event_type (string), $order (WC_Order), $notification (object).
Return Value: A string replacing the rendered message.
add_filter( 'wprr_sfwco_notification_message', function( $message, $event_type, $order, $notification ) {
if ( 'new_order' === $event_type ) {
$message .= "\n*Store Priority:* High Value Customer";
}
return $message;
}, 10, 4 );
wprr_sfwco_notification_payload
Purpose: Modify the Slack request payload array before transmission.
Arguments: $payload (array containing 'text'), $event_type (string), $order (WC_Order), $notification (object).
Return Value: An array containing a string text field. Slack Incoming Webhook capabilities and payload requirements apply.
add_filter( 'wprr_sfwco_notification_payload', function( $payload, $event_type, $order, $notification ) {
// Add custom username or formatting
return $payload;
}, 10, 4 );
13.4 Recommended Developer Practices
- Keep callback execution fast to prevent delays in background execution queues.
- Always return the expected data type from each filter callback.
- Avoid changing notification behavior without testing all six events thoroughly.
- Never log customer personal data or secrets to external unencrypted logs.
- Always test integrations on a staging site before deploying to production.
- Review the plugin source before upgrading because pre-release hook signatures may evolve.