Please add this to your functions.php
/* Custom functions code goes here. */
add_shortcode( ‘stockis’, ‘display_product_stock_status’ );
function display_product_stock_status( $atts) {
$atts = shortcode_atts(
array(‘id’ => get_the_ID() ),
$atts, ‘stock_status’
);
if( intval( $atts[‘id’] ) > 0 && function_exists( ‘wc_get_product’ ) ){
$product = wc_get_product( $atts[‘id’] );
$stock_status = $product->get_stock_status();
$stock_quantity = $product->get_stock_quantity();
if ( ‘instock’ == $stock_status) {
if ( $stock_quantity <4 ) {
$html = ‘<p class=”stock in-stock”>🟠</p>’;
}
else {
$html = ‘<p class=”stock in-stock”>🟢</p>’;
}
}
else {
$html = ‘<p class=”stock out-of-stock”>🔴</p>’;
}
}
return $html;
}
then use the shortcode [stockis] wherever you want
the orange limit is here
if ( $stock_quantity <4 )
chage 4 to whatever you want