Every time you try and set a custom/action topic within webhooks (from WooCommerce > Settings > Webhooks) it would unset it as soon as you update your changes to the webhook. In other words, it will undo your custom topic and return it back to ‘Select an option’ for the topic dropdown.
Any help at all is appreciated. Thank you very much!
edit: In addition to my comment below, I’ve also attempted to create my own custom topic via the following filter woocommerce_webhook_topic_hooks
, however, it doesn’t show within the dropdown list as an option.
The below code runs from functions.php
as with any WordPress hook..
Code
function custom_woocommerce_webhook_topics( $topic ) {
$topic['order.refunded'] = array(
'woocommerce_process_shop_order_meta',
'woocommerce_api_edit_order',
'woocommerce_order_edit_status',
'woocommerce_order_status_changed'
);
return $topic;
}
add_filter( 'woocommerce_webhook_topic_hooks', 'custom_woocommerce_webhook_topics', 10, 1 );
edit 2: Added more context
I was having the same issue. Selecting any of the built-in topics worked fine. But selection Action and entering any WooCommerce Subscription actions kept reverting. I had also tried creating a new custom topic in the same file (wp-content/plugins/woocommerce-subscriptions/includes/class-wcs-webhooks.php) that the built-in topics are created, mirroring 1:1 the code of one of the topics that ‘stick’ (e.g subscription.created) for a new ‘subscription.paymentcomplete’ topic. It appears in the drop down, but after saving the drop-down reverts to the default ‘Selection an option…’.
The solution was: