Hello,
A while ago I received this piece of code to hide categories that are not checked B2B. It works but strangely enough it skips some categories even if that categorie is unchecked for B2B. Is there some parameter that prevents the css class from being placed?
//B2B hide cats
function add_class_to_empty_category_menu_item($classes, $item) {
if ($item->object == 'product_cat') {
$category_id = $item->object_id;
$user_id = get_current_user_id();
$is_b2b = get_user_meta($user_id, 'b2bking_b2buser', true);
if ($is_b2b === 'yes'){
$group_id = get_user_meta($user_id, 'b2bking_customergroup', true);
$group_visibility = get_term_meta($category_id, 'b2bking_group_'.$group_id, true);
if (intval($group_visibility) === 0){
$classes[] = 'niksdrin'; // Add your custom class here
}
}
}
return $classes;
}