Okay
  Public Ticket #2673877
Category Visibility
Closed

Comments

  • [deleted] started the conversation

    Hey guys, how do I disable a categories visibility to B2C customers and only show to a specific B2B group? After setting all the below settings, the PRODUCT is hidden from B2C customers however, the CATEGORY is still showing to B2C customers? See screenshot attached. I want to hide it from them.

    All products Visible: Off

    Enable Hidden has Priority: On

    Guest Restriction: Hide shop & products

    Plugin Status: B2B & B2C Hybrid

    Category Settings are attached as screenshot.

  •  2,217
    WebWizards replied

    Hi Kyle,

    Thank you for purchasing our plugin.


    While the plugin can hide products, it can't hide menu items natively. One solution would be to hide these via CSS by adding a specific snippet.

    In the snippet below you would have to replace cat-item-7922 with the class of your category.

    // Apply CSS for B2C and Logged Out users only
    add_action('wp_head','b2c_only_css');
    function b2c_only_css(){
       // check that user is not B2B
       if (get_user_meta(get_current_user_id(), 'b2bking_b2buser', true) !== 'yes'){
          ?>
          <style>
          .cat-item-7922{
              display:none;
          }
          </style>
        <?php
          }
    }
    


    Kind Regards,

    Stefan


  •  1
    Steph replied

    HI, can you tell me where in Wordpress I am to post the snip-it of code below to hide the category? and where i can find what the cat-item-### is for the category I am trying to hide?

  •  2,217
    WebWizards replied

    Hi Steph,

    The bellow snippet is a PHP snippet. To add that to your site, kindly please follow the instructions in this article:

    https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/


    To get the ID of your category, you can go in the backend to Products -> Categories and click on the category:

    8336847266.png

    The number in the link is the category ID:

    3506811681.png

    in the above example it is 15. Therefore, the class would be '.cat-item-15'


    Let me know if I can help,

    Kind regards,

    Stefan