Thanks to the help of two fellow members of this forum I have managed to get the snippet working.
Here I leave the solution for any future answer seeker who happens to stop by.
add_action( 'wp_head', function () {
//Get current user ID, if the user is logged in.
if ( is_user_logged_in() ) {
$user_id = get_current_user_id(); }
// Get the user object.
$user = get_userdata( $user_id );
// Get all the user roles for this user as an array.
$user_roles = $user->roles;
// Check if the specified role is present in the array.
if ( in_array( 'customer_2', $user_roles, true ) ) { ?>
<style>
.woofs-additional, .woofs-total {display: none!important;}
</style>
<?php
}
} );