Out of stock remove add to cart on variable products
-
Hi,
Not sure if this can be achieved but on simple products when the product is out of stock the add to cart button is not shown on the website. Just wondering if this can be done on variable products as well? Obviously more complicated as you would only want the button removed on the variation that was out of stock and leave it there for the variations that are in stock on the same product.
Look forward to your reply. Thanks.
Hello,
A variable product would have Add to cart as this button relates to the whole product, not to a certain variation.
This is Woocommerce functionality and our theme does not influence that.
Best Regards
Ok, no problem. Thank you for your reply.
Heyy!
Use this snippet…add it to your funtctions or use wordpress Snippets plugin
Grey-out Out of Stock Variations – That what it does 😉
add_filter( 'woocommerce_variation_is_active', 'bbloomer_grey_out_variations_out_of_stock', 10, 2 );
function bbloomer_grey_out_variations_out_of_stock( $is_active, $variation ) {
if ( ! $variation->is_in_stock() ) return false;
return $is_active;
}
Thank me later 😉
Hi Priit,
Doesn’t seem to do anything for me, must be something else conflicting.
Not sure it is quite what I want to achieve anyway as I have a back in stock notification that I would still like to show. Just wanting to hide the add to cart button.
Thanks for trying.