show/hide "add to cart button" show for 2 hide the rest

I need to show “add to cart button” for two products and remove the “add to cart” button for all products.

A google search led me to this code for hiding the “add to cart” button by marking the items purchasable=false. Is it possible to make 2 items true and the others false?

Here is the code I’m using to hide the button

/* Hide Add to Cart Button*/

add_filter( 'woocommerce_is_purchasable', false );

The products that need “true” -> Id= 21,21

using wordpress and woocommerce. I have search for a solution but haven’t been able to find one. Thank you in advance for your help.

Read more here: show/hide "add to cart button" show for 2 hide the rest

Leave a Reply

Your email address will not be published. Required fields are marked *