Hi,
I'm using views to create my woocommerce archive pages and display the products in there with a content template.
Now, some of the products I'm showing to the public, have NO RETAILPRICE set, because these products are only to be sold to wholesale customers.
I want to present the non logged in users and the normal customers with a extra message that these products are wholesale only.
The first part is easy:
[wpv-if arg1="_price" evaluate="empty($arg1)"]No url given[/wpv-if]
Wholesale only products don't have a normal retailprice, so with above code I can show a warning on the products to check is the _price field is empty.
Only problem: when a wholesale customer (role = wholesale) is logged in, he/she also sees this message. I don't want that.
In my functions.php I have:
function appthemes_check_user_role( $role, $user_id = null ) {
if ( is_numeric( $user_id ) )
$user = get_userdata( $user_id );
else
$user = wp_get_current_user();
if ( empty( $user ) )
return false;
return in_array( $role, (array) $user->roles );
}
When I use this in my own functions.php to hide content when a user is logged in as 'wholesale customer', this is working.
I now trie to use it with TVC toolset like this:
[wpv-if evaluate="appthemes_check_user_role( 'customer') = 'false'"]Tagged Test[/wpv-if]
or
[wpv-if evaluate="appthemes_check_user_role( 'customer') = 'true'"]Tagged Test[/wpv-if]
or
[wpv-if evaluate="appthemes_check_user_role( 'customer')"]Tagged Test[/wpv-if]
Nothing working. What am I doing wrong?
And how to merge both, so that is it showing the message when _price field is empty, except when the customer is logged in als 'wholesale'...
Kind regards,
Willem