Display WooCommerce only in stock sizes product attribute on shop page
Question
The following code from a previous answer to one of my questions displays Woocommerce “Size” product attributes below each product on the shop page:
add_action( 'woocommerce_after_shop_loop_item_title', 'display_size_attribute', 5 );
function display_size_attribute() {
global $product;
if ( $product->is_type('variable') ) {
$taxonomy = 'pa_size';
echo '<span class="attribute-size">' . $product->get_attribute($taxonomy) . '</span>';
}
}
How do I change the code to only display “in-stock” items (of product attribute “Size”)?
0
woocommerce
4 years
2019-08-06T21:21:21-05:00
2019-08-06T21:21:21-05:00 0 Answers
76 views
0
Leave an answer