Support » Plugin: WooCommerce » hide out-of-stock attributes in post but show that in shop or search

  • Resolved amesmaili

    (@amesmaili)


    hi
    i want to hide or blur the product attribute in post which is out of stock.
    but also i want the out of stock product shows in the shop page or search results and …
    is there any soloution?

    for example:
    when the XL size of a pants is not in stock, the attribute of XL become blue or hide and the customer cant select that. but also i want when the whole sizes are out of stock, the pants remain in shop page and customers can view the pants post.

    this option doesnt cover my need!!!
    WooCommerce > Settings > Products > Inventory > Out of Stock Visibility

    • This topic was modified 1 year, 4 months ago by amesmaili.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello,

    when the XL size of a pants is not in stock, the attribute of XL become blue or hide and the customer cant select that. but also i want when the whole sizes are out of stock, the pants remain in shop page and customers can view the pants post.

    This is possible with some custom code – leave the out of stock visibility unchecked, and use the code below to gray out variations that are out of stock:

    add_filter( 'woocommerce_variation_is_active', 'grey_out_variations_when_out_of_stock', 10, 2 );
    
    function grey_out_variations_when_out_of_stock( $grey_out, $variation ) {
    
        if ( ! $variation->is_in_stock() )
            return false;
    
        return true;
    }

    Code source: https://stackoverflow.com/questions/29879413/greying-out-out-of-stock-product-variations-woocommerce/#answer-29881688

    I would recommend using a plugin like Code Snippets to add the snippet to your site.

    Thread Starter amesmaili

    (@amesmaili)

    thanks for the answer.
    unfortunately its not the solution for me.
    because the example of pant is a simple one which is not my case. i have multiple variation.

    i thinks what i want is the need of every woocommerce web site. i wonder how the is no plugin to cover this.

    Plugin Support abwaita a11n

    (@abwaita)

    Hi @amesmaili,

    because the example of pant is a simple one which is not my case. i have multiple variation.

    Thanks for the explanation.

    Checking the code referenced by @maykato, I see that it is for variations. You could give it a try and see if it works for you.

    i wonder how the is no plugin to cover this.

    I’ve searched around and found a third-party plugin that advertises this functionality – https://pluginrepublic.com/wordpress-plugins/woocommerce-better-variations/.

    If you have questions about the plugin, kindly contact the plugin authors on the plugin’s support page.

    Hope this helps.
    Thanks.

    Thread Starter amesmaili

    (@amesmaili)

    hi @abwaita
    thanks for the reply

    i have checked the code. it doesnt cover my case.

    there are lots of plugings which do the same as the one you found. woocommerce has the same functionality built in too.
    they do the best in product page and varations but the problem is in the shop page.

    the shop page is the list of products.
    if we set the “WooCommerce > Settings > Products > Inventory > Out of Stock Visibility” to false, out of stocks wont be shown in the list.

    Plugin Support Adam Heckler

    (@adamkheckler)

    The code snippet my colleague showed above does indeed gray out product variations if they are out of stock.

    Example product configuration: https://d.pr/i/0bJd2r/1vLjGcA5ho

    The result with the snippet applied: https://d.pr/i/c1CPhj/ig42MH8gsc

    As you can see, it’s not selectable.

    However, what WooCommerce cannot do by default is show individual variations in the shop page. It shows variable products like this: https://d.pr/i/buTEsm/wQnknCcIPP It does not list out each individual variation as its own entry. You would need a separate plugin or bit of custom code for that.

    At this point, I think we’ve reached the limit of what we can support, since custom code like this is outside our support policy. I’ll leave this thread open for other folks to contribute to if they wish though.

    Sorry I can’t be of more help here! 🙁

    Hi @amesmaili

    We’ve not heard back from you in a while, so I’m marking this thread as resolved. If you have further questions, please feel free to open a new topic.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘hide out-of-stock attributes in post but show that in shop or search’ is closed to new replies.