Created
February 14, 2023 17:28
-
-
Save mircobabini/e0cd068002718f2d98a1690aca00a55b to your computer and use it in GitHub Desktop.
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 | |
define( 'INVOICE_GENERATION_MINIMUM_SUBTOTAL', 100 ); // se subtotale >= X€ IVA ESCUSA, allora genero la fattura | |
add_filter( 'wpo_wcpdf_document_is_allowed', function ( $allowed, $document ) { | |
if ( ! $document->exists() && ! empty( $order = $document->order ) ) { | |
if ( ! is_callable( array( $order, 'get_subtotal' ) ) ) { | |
return false; | |
} | |
// check order total & setting | |
$order_subtotal = $order->get_subtotal(); | |
if ( $order_subtotal < INVOICE_GENERATION_MINIMUM_SUBTOTAL ) { | |
return false; | |
} else { | |
return $allowed; | |
} | |
} else { | |
return $allowed; | |
} | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment