//Please give a thumbs up if this was helpfull
//So I can see 2 separate issues in this question.
//First one being "how to display only products belonging to certain user role"
//For this, you might wanna alter the woocommerce product query. You can do so by adding something like the following code to your theme's functions.php:
<?php
function filter_products_by_user_roles( $q ) {
if (is_user_logged_in()) {
$user_meta = get_userdata(get_current_user_id());
$user_roles = $user_meta->roles;
$tax_query = array('relation' => 'OR');
foreach ($user_roles as $role) {
$tax_query[] = array(
'taxonomy' => 'product_tag',
'field' => 'slug',
'terms' => $role,
);
}
$q->set( 'tax_query', $tax_query );
$q->set( 'posts_per_page', '30' );
$q->set( 'post_type', 'product' );
$q->set( 'post_status', 'publish' );
}
}
add_action( 'woocommerce_product_query', 'filter_products_by_user_roles' );
?>
//This code will take all of the user's roles and add them 1 by 1 to the product query filter based on product_tag, which is essential for this. The slug of assigned product tag must match the user role name. for example: user role is "VIP_user_2" so the tag assigned to desired products must be "VIP_user_2"
//Second one is "How to display different prices for different user roles"for this, we will have to edit woocommerce files, so first go through this guide on how to safely edit such files: https://woocommerce.com/document/template-structure/
//Once your theme is prepared, you can edit the woocommerce/loop/price.php with your own condition and the values / db fields you want to fill in for users
//The default code in price.php is:
<?php if ( $price_html = $product->get_price_html() ) : ?>
<span class="price"><?php echo $price_html; ?></span>
<?php endif; ?>