Prevent InvoiceXpress document issuing on WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* https://invoicewoo.com/ */ | |
add_filter( 'invoicexpress_woocommerce_prevent_document_issuing', 'my_prevent_document_issuing', 10, 5 ); | |
function my_prevent_document_issuing( $prevent_document_issuing, $order_object, $document_type, $data, $mode = 'manual' ) { | |
if ( ! $prevent_document_issuing['prevent'] ) { | |
//Check whatever you want, for example on the order, and prevent issuing | |
if ( $order_object->get_total() > 100 ) { | |
$prevent_document_issuing['prevent'] = true; | |
$prevent_document_issuing['message'] = 'The order was not invoiced because the total is above 100'; | |
$prevent_document_issuing['supress_error'] = true; // To not get the "document not issued" email | |
} | |
} | |
return $prevent_document_issuing; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment