Slack for WooCommerce lets developers change what each notification says with WordPress filters. Add them in a custom plugin or your theme’s functions.php. These filters apply to the settings screen under WooCommerce » Slack; stores still on the 1.x connection run older code (see the note at the end).
Customizations aren’t covered by support. If you need help with code, work with a WordPress developer.
Message filters
Each event’s message passes through a filter after its merge tags are filled in. The value is the message text in Slack’s formatting, so links use <url|text>.
| Event | Filter | Arguments |
|---|---|---|
| New order | wcslack_new_order_message | $message, $order_id |
| Order update | wcslack_order_update_message | $message, $order_id |
| Refund | wcslack_refund_message | $message, $order_id |
| Subscription renewal | wcslack_sub_renew_new_message | $message, $order_id |
| Back order | wcslack_back_order_message | $message |
| Low stock | wcslack_low_stock_message | $message |
| Out of stock | wcslack_out_stock_message | $message |
| New review | wcslack_new_review_message | $message |
| New customer | wcslack_new_customer_message | $message |
| New post | wcslack_new_post_message | $message |
For example, to add the payment method to every new order message:
add_filter( 'wcslack_new_order_message', function( $message, $order_id ) {
$order = wc_get_order( $order_id );
return $order ? $message . ' (' . $order->get_payment_method_title() . ')' : $message;
}, 10, 2 );
Details filters
When Extended is on, the details block below the message is built from a list of fields. Each field is an array with title, an optional value, and short (true puts two fields side by side). The filters run before the line items and totals are added.
| Event | Filter | Arguments |
|---|---|---|
| New order | wcslack_new_order_attachment | $fields, $order_id, $order |
| Order update | wcslack_order_update_attachment | $fields, $order_id, $order |
| Refund | wcslack_refund_attachment | $fields, $refund_id, $refund |
| Subscription renewal | wcslack_sub_renew_new_attachment | $fields, $order_id, $order |
| New review | wcslack_new_review_attachment | $fields |
| New post | wcslack_new_post_attachment | $fields |
Value filters
These change a single value before it goes into the message’s tags.
| Filter | Value |
|---|---|
wcslack_new_review_reviewer_name | The reviewer’s name |
wcslack_new_review_product_name | The reviewed product’s name |
wcslack_new_review_content | The review text |
wcslack_new_review_rating_star | The emoji repeated once per star, :star: by default |
wcslack_new_review_url | The link to the review |
wcslack_new_customer_name | The customer’s display name |
wcslack_new_customer_url | The link to the customer’s profile in your admin |
wcslack_new_post_title | The post title |
wcslack_new_post_content | The post content, with HTML removed |
wcslack_new_post_author | The author’s display name |
wcslack_new_post_url | The post’s address |
Other filters
wcslack_message_username
Filters the sender name for every message, including the test notification. It receives the Sender name setting; return an empty string to use the Slack app’s own name.
wcslack_post_publish_types
The post types that send New post, [ 'post', 'page' ] by default. To include products:
add_filter( 'wcslack_post_publish_types', function( $types ) {
$types[] = 'product';
return $types;
} );
Stores still on the 1.x connection
Until a store clicks Switch to the new experience, it runs the 1.x code, which also has wcslack_*_prefix filters for each message’s opening text. The settings screen in version 2.0.0 and later doesn’t use those filters, so move any prefix change into the event’s Message field or a message filter when you switch.
Keep learning
- Get started with Slack (settings, events and merge tags)
- Upgrade from version 1.x
