[ad_1]
Hi @sirrahikkala,
Do you mean the user role of the customer? If so, please try with this code snippet I just wrote for you:
/**
* WooCommerce PDF Invoices & Packing Slips for WooCommerce:
* Display the customer role on the PDF document (except for guest customers)
*/
add_action( 'wpo_wcpdf_after_billing_address', function( $document_type, $order ){
if ( $document_type == 'invoice' && $customer_id = $order->get_customer_id() ){
if ( $user = get_user_by( 'id', $customer_id ) ) {
global $wp_roles;
$all_roles = $wp_roles->roles;
$user_role = $user->roles[0];
foreach ( $all_roles as $role_key => $role_details ) {
$user_role = ( $role_key == $user_role ) ? $wp_roles->roles[$user_role]['name'] : $user_role;
break;
}
if ( $user_role ) {
echo '<div>Customer Role: ' . $user_role . '</div>';
}
}
}
},10, 2 );If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters
We are always happy to help, @sirrahikkala!
If you don’t mind and have the time, do you think you could leave us a review?
Thanks in advance and all the best with your store!
