我想将文本Only 1.000000e+0ft in stock!
改写为1 left in stock
,并在下面的代码段中使用,但同时显示两个文本,我只希望一个文本为1 left in stock
add_action('woocommerce_after_shop_loop_item','bbloomer_show_stock_shop', 5);
function bbloomer_show_stock_shop()
{
global $product;
if ( $product->stock )
{ // if manage stock is enabled
if ( number_format( $product->stock,0,'','' ) < 3 )
{ // if stock is low
echo '<div class="remaining">' . number_format($product->stock,0,'','') . ' left in stock</div>';
}
else
{
echo '<div class="remaining">' . number_format($product->stock,0,'','') . ' left in stock</div>';
}
}
}
我做错了,因为它现在同时显示两者。