// Out of stock for general woocommerce – might help someone
function product_in_stock($post, $product) {
if (!$product->is_in_stock()) {
$STOCK = TRUE;
return $STOCK;
} else {
return false;
}
}
function check_if_out_of_stock(){
global $post,$product;
$stock = product_in_stock($post,$product);
$output="<div class="";
$output .= $stock?"instock":"outofstock";
$output .= '">';
echo $output;
}
add_action( 'woocommerce_before_shop_loop_item', 'check_if_out_of_stock');
function close_out_of_stock(){
echo "</div>";
}