Skip to content

Instantly share code, notes, and snippets.

@webdados
Last active November 30, 2023 10:44
Show Gist options
  • Save webdados/e952ccea4326b2e4cfc3c7af50ff5f69 to your computer and use it in GitHub Desktop.
Save webdados/e952ccea4326b2e4cfc3c7af50ff5f69 to your computer and use it in GitHub Desktop.
Prevent InvoiceXpress document issuing on WooCommerce
<?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