在woocommerce主题中,我试图在产品缺货时发出警告。类似这样:
<?php if (\'this_product_is_out_of_stock\'): ?>
<p>This product is out of stock. It can be purchased by custom made order.</p>
<?php endif; ?>
是否有一个函数来表示“this\\u product\\u Is\\u out\\u of\\u stock”或其他方式来实现它?
我搜索woocommerce api文档失败:https://docs.woocommerce.com/wc-apidocs/
提前谢谢你。
最合适的回答,由SO网友:Alvin Zachariah 整理而成
试试这样的
global $product;
if ( ! $product->managing_stock() && ! $product->is_in_stock() )
echo \'<p>This product is out of stock. It can be purchased by custom made order.</p>\';