• Resolved gergeda008

    (@gergeda008)


    hallo, sorry for my english i use google translator for this ??

    i want to hide outofstock products for customer but products should not be hidden for the admin

    can you help me with this?

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hello,

    If you want to hide outofstock products from the plugins search results than simply go to the plugin settings page turn off ‘Show out-of-stock’ option.

    Regards

    Thread Starter gergeda008

    (@gergeda008)

    hallo @mihail-barinov

    Thanks for responding.

    yes, I know about this option,
    but this option hides products not only for the buyer but also for the administrator…

    i just want to add a line `<?php if( current_user_can(‘manage_woocommerce’)) { ?>
    /*here should be a code that shows out of stock product for administrator ( this is what i’m looking for ) */
    <?php } ?> `

    thanks

    Plugin Author ILLID

    (@mihail-barinov)

    Looks like I found the solution for you. Please use following code snippet

    add_filter( 'aws_search_query_array', 'my_aws_search_query_array' );
    function my_aws_search_query_array( $query ) {
        if ( current_user_can( 'manage_options' ) ) {
            $query['stock']  = '';
        }
        return $query;
    }

    You need to add it somewhere outside the plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.

    Also after adding this code you will need to go to the plugin settings page and click the ‘Clear cache’ button.

    Regards

    Thread Starter gergeda008

    (@gergeda008)

    thank you very much! @mihail-barinov
    works great!

    i will share my appreciations by rating your plagin

    Plugin Author ILLID

    (@mihail-barinov)

    Glad to help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘show outofstock product only for admin’ is closed to new replies.