Hello Pierre-Marie,
This is possible but would require a little bit of custom PHP coding. You could use the wpo_wcpdf_custom_attachment_condition
.
Here’s an example, you will need to tweak it so that it actually reads your checkbox value from the order data:
add_filter( 'wpo_wcpdf_custom_attachment_condition', 'wpo_wcpdf_only_invoice_requested', 20, 4 );
function wpo_wcpdf_only_invoice_requested( $attach, $order, $email_id, $document_type ) {
$wants_invoice = $order->get_meta('_invoice_checkbox');
if ( empty($wants_invoice) ) {
return false; // don't attach when invoice checkbox wasn't checked
}
return $attach; // use plugin attachment settings
}
If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters
Hope that helps!