Display 'In-stock' and 'Out-of-stock' status in archive / Not the stock quantity
-
Good day.
I have been searching for days on how to display the stock status in archive page of woocommerce. These are some of the snippet that I have been trying
// PHP add_action( 'woocommerce_before_shop_loop_item_title', function() { global $product; if ( !$product->is_in_stock() ) { echo '<span class="soldout">SOLD OUT</span>'; } });
// display an 'Out of Stock' label on archive pages add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_stock', 10 ); function woocommerce_template_loop_stock() { global $product; if ( ! $product->managing_stock() && ! $product->is_in_stock() ) echo '<p class="stock out-of-stock">Out of Stock</p>'; }
But these do not work when I input into my theme’s functions.php
Please help me what code to input? or where exactly should I input the code?
Any help is much appreciated. Thank you so much.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Display 'In-stock' and 'Out-of-stock' status in archive / Not the stock quantity’ is closed to new replies.