Skip to content

Instantly share code, notes, and snippets.

@Kaiderella
Created August 19, 2021 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kaiderella/9b9a56f5d5bf171de51604bbdfc939d4 to your computer and use it in GitHub Desktop.
Save Kaiderella/9b9a56f5d5bf171de51604bbdfc939d4 to your computer and use it in GitHub Desktop.
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