Skip to content

Instantly share code, notes, and snippets.

@mikejolley
Last active November 7, 2019 13:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mikejolley/1751128 to your computer and use it in GitHub Desktop.
Save mikejolley/1751128 to your computer and use it in GitHub Desktop.
WooCommerce - Hide loop buttons for out of stock items
/*
* Override via functions.php
**/
if (!function_exists('woocommerce_template_loop_add_to_cart')) {
function woocommerce_template_loop_add_to_cart() {
global $product;
if ( ! $product->is_in_stock() || ! $product->is_purchasable() ) return;
woocommerce_get_template('loop/add-to-cart.php');
}
}
@ParadoxDesign
Copy link

Cool

How might I revise this to display "out of stock" instead of the Read More button?

Thanks

@mediumandmessage
Copy link

With Woo 3.3 changes to stock management, this gist no longer filters on stock status. Ideas how to fix / update?

@tauclement
Copy link

Hi @MedMess, Have you found a fix for the above?

@BenKalsky
Copy link

How can I change loop button instead of hiding it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment