Public Ticket #3527396

Sales Agents Stock

Closed
Comments
17 Tickets 18
Darren Robinson started the conversation 3 years ago on November 22, 2023 at 9:46am

Hi Stefan,

Currently anyone with the 'reps' user role can see the available stock. I would like it so only sales agents shopping as a customer can see the stock quantites?

You gave me some code previously that only allows sales agents shopping as a customer to see the products on back order and i wondered if this is possible with the stock levels so only sales agents shopping as a customer can see stock?

Thanks for your time

Darren

2,762
KingsPlugins replied 3 years ago on November 25, 2023 at 7:03pm

Hi Darren,

If you still have the previous code snippet on your site, I believe it should work to do the following:


1. In WooCommerce -> Settings -> Products -> Inventory, set it to https://prnt.sc/8qOlCcg4IxRM

2. Add this PHP snippet to your site:

add_filter('option_woocommerce_stock_format', function($val){
    if (check_user_is_agent() or check_is_agent()){
        return '';
    }
    return $val;
}, 10, 1);


Let me know if that works for you,


Kind regards,

Stefan

Sign In