'Block certain WooCommerce webhooks from firing

In the application I am running, we need to stop certain orders from getting sent to inFlow inventory management.

I want to stop orders with the status of Estimate from making it all the way through the process.

From what I've read, hooking into woocommerce_webhook_should_deliver and returning $should_delever == false should stop the webhook from firing, but I am unable to get it to.

function should_deliver_order_creation($should_deliver, $wc_webhook, $arg) {
    $order = wc_get_order($arg);
    $order->get_status();
    if(str_contains($wc_webhook->get_name(), 'inFlow') && $order->get_status() == 'estimate') {
        $should_deliver = false;
    }
    return $should_deliver;
}

add_filter('woocommerce_webhook_should_deliver', 'should_deliver_order_creation', 9, 3);

Orders with a status of 'estimate' are still going through

Are there any other hooks I should try to get into to to make the order stop going through?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source