Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

ParadoxDesign commented Dec 19, 2013

Cool

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

Thanks

@MedMess

This comment has been minimized.

Copy link

MedMess commented Feb 21, 2018

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

@tauclement

This comment has been minimized.

Copy link

tauclement commented Feb 28, 2018

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

@BenKalsky

This comment has been minimized.

Copy link

BenKalsky commented Nov 7, 2019

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
You can’t perform that action at this time.