[ad_1]
Hi @estebanip,
Here is not only a code snippet example, but the actual one that works for your case:
/**
* WooCommerce PDF Invoices & Packing Slips
* Deactivate invoice for specific products
*/
add_filter( 'wpo_wcpdf_document_is_allowed', function( $is_allowed, $document ) {
if ( ! empty( $order = $document->order ) && $document->get_type() == 'invoice' && ! $document->exists() ) {
$disallowed_products = [ 123, 321 ]; // Add all your disallowed products IDs here separated by comma
foreach ( $order->get_items() as $item_id => $item ) {
if ( in_array( $item->get_product_id(), $disallowed_products ) ) {
$is_allowed = false;
}
}
}
return $is_allowed;
}, 10, 2 );If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters
Just replace the product IDs within the $disallowed_products with the actual product IDs 😉
