Skip Invoice for Cancelled & Failed Order in WooCommerce PDF Invoice Plugin

I am wanting to skip the invoice for my cancelled & failed order. I am using the WooCommerce PDF Invoice plugin. It is very simple and easy job. Plugin have a filter bewpi_skip_invoice_generation. So you can do it without editing the core plugin.

function cpaul_skip_invoice_generation( $bool, $status, $order ) {
    /**
     * wc-failed slug is for Failed order
     * wc-cancelled slug is for Cancelled order
     */
    if( $status == "wc-failed" || $status == 'wc-cancelled' )
    	return true; // true to skip

    return bool;
}
add_filter( 'bewpi_skip_invoice_generation', 'cpaul_skip_invoice_generation', 10, 3 );

Just drop the above code into your functions.php file or custom plugin’s file and see the magic.

This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.