Hi @lilingg
Yes, it’s possible.
First you need to attach the Invoice to an email under PDF Invoices > Documents > Invoice > Attach to, and finally you need to add the code snippet below:
add_filter( 'wpo_wcpdf_custom_attachment_condition', function( $condition, $order, $email_id, $document_type ) {
if ( ! empty( $order ) && 'invoice' === $document_type ) {
$user = $order->get_user();
$user_roles = (array) $user->roles;
if ( ! in_array( 'wholesale', $user_roles ) ) { // 'wholesale' role slug
$condition = false;
}
}
return $condition;
}, 10, 4 );
If you never worked with code snippets, please read this documentation page: How to use code snippets
I have considered the role slug as wholesale
, but depending on the plugin it can be different, and you might need to update in the code.
-
This reply was modified 7 months, 3 weeks ago by
alexmigf.