Client now wants to be able to turn ON and OFF WooCommerce Products for sale

Hello, this might be a ridiculous question, but we spent many days custom coding a special function that enables from the back end the uploading of "blue prints" for model homes that are WooCommerce products. The client now says he wants these items to be not for sale (more or less be regular wordpress pages). Is there any way to just "turn off" the Add to Cart button on certain products? It would be way too much effort to turn all his products into static pages...plus it wouldn't look good! Anyways, your thoughts are appreciated thank you

AD

  • Vaughan

    Hi @adrian,

    I don't think this would be possible out of the box. Though i'm not experienced with woocommerce at all.

    A solution would be possibly if you could edit the woocommerce templates loop.

    Then in the loop, you grab the product id

    So you make an array of item id's (say in your themes header.php)

    $hidden = array(1,2,3,4,5,6);

    So now in the template loop for the products.

    You grab the product_id

    Then modify the div for the item in the loop, for example.

    $hide = (in_array($product_id, $hidden)) ? '-hidden' : '');
    <div class="product-item<?php echo $hide; ?>">

    So then you just create a new CSS class:

    .product-item-hidden {
        display: none;
    }

    What the above would essentially do, is check if the product_id is in the array, if it is, then the div class is appended with -hidden & your CSS then does the rest.

    Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.