Skip to content

Instantly share code, notes, and snippets.

@Kaiderella
Created Aug 19, 2021
Embed
What would you like to do?
Hide Add to Cart Button for Out of Stock Products
function wpcb_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', 'wpcb_remove_out_of_stock_product_button', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment