hello,
after some help….
I have a woocommerce store that sells variable products.
e.g Blowgun variable: single item box of 4
Im trying to make it so variable products will not show the single item when logged in. Ive got it to a point where itll hide the option label text but doesnt remove option all together.
[varaible options])Code used:
add_filter(‘woocommerce_variation_option_name’, ‘custom_hide_single_item_option’, 10, 1); function custom_hide_single_item_option($term_name) { // Get the current user’s roles $user = wp_get_current_user(); $user_roles = (array)$user->roles; // Define the roles to exclude $roles_to_exclude = array(‘reseller’, ‘reseller 1’, ‘administrator’); // If the user has any of the excluded roles, remove the “Single Item (1pc)” option if (array_intersect($user_roles, $roles_to_exclude) && $term_name === ‘Single Item (1pc)’) { return false; } return $term_name; }
[ad_2]