/** * Hide out of stock product button. * * @param string $html * @param WC_Product $product * @param array $args * @return string */ function ace_remove_out_of_stock_product_button( $html, $product, $args ) { if ( ! $product->is_in_stock() && ! $product->backorders_allowed() ) { return ''; } return $html; } add_filter( 'woocommerce_loop_add_to_cart_link', 'ace_remove_out_of_stock_product_button', 10, 3 );
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter