It doesn’t work, I have the following codes added in my wordpress child theme:
add_filter( 'wpo_wcpdf_document_is_allowed', function( $allowed, $document ) {
if ( ! empty( $document ) && ! empty( $order = $document->order ) && $document->get_type() == 'invoice' ) {
$user = $order->get_user();
if ( ! empty( $user ) && in_array( 'cod', (array) $user->roles ) ) { // replace with another role
$allowed = false;
}
}
return $allowed;
}, 10, 2 );
add_filter( 'wpo_wcpdf_document_is_allowed', function( $allowed, $document ) {
if ( ! empty( $document ) && ! empty( $order = $document->order ) && $document->get_type() == 'invoice' ) {
$user = $order->get_user();
if ( ! empty( $user ) && in_array( 'cheque', (array) $user->roles ) ) { // replace with another role
$allowed = false;
}
}
return $allowed;
}, 10, 2 );
I show you in video the codes of each payment method and as you can see the invoice is still attached and I don’t want it to be attached: https://loom.com/share/523b32ccf3cf40879096995f9e5b8afc
Thank you for your help