I interpret that as ‘just the automatic creation’ then ??
Here’s an example filter you can use for that:
add_filter( 'wpo_wcpdf_custom_attachment_condition', 'wpo_wcpdf_exclude_products', 100, 4 );
function wpo_wcpdf_exclude_products( $condition, $order, $status, $template_type ) {
// only apply check on invoices
if ($template_type != 'invoice') {
return $condition;
}
// define product IDs which shouldn't get an invoice here
$no_invoice_products = array( 101, 102 );
// loop through order items and cancel attachment if one of the products present
$items = $order->get_items();
foreach ($items as $item_id => $item) {
if (in_array($item->get_product_id(), $no_invoice_products)) {
// matching product, don't attach invoice
return false;
}
}
// if we got here, there were no matching products
return $condition;
}
If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters
You can change the product ID’s in the snippet with the ones you want to disable the invoice for.
Hope that helps!