最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

functions - How to get woocommerce inventory status

programmeradmin6浏览0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 8 years ago.

Improve this question

In a woocommerce theme, Im trying to show a warning when product is out of stock. Something like this:

<?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; ?>

Is there a function to say 'this_product_is_out_of_stock' or some other way to achieve it?

I was searching woocommerce api docs unsuccesfully: /

Thank you in advance.

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 8 years ago.

Improve this question

In a woocommerce theme, Im trying to show a warning when product is out of stock. Something like this:

<?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; ?>

Is there a function to say 'this_product_is_out_of_stock' or some other way to achieve it?

I was searching woocommerce api docs unsuccesfully: https://docs.woocommerce/wc-apidocs/

Thank you in advance.

Share Improve this question asked Sep 4, 2016 at 6:54 aitoraitor 7252 gold badges8 silver badges23 bronze badges 1
  • 1 Questions about the inner workings of third party plugins are better asked at their author's forum, in this case: wordpress/support/plugin/woocommerce – cjbj Commented Sep 4, 2016 at 14:27
Add a comment  | 

1 Answer 1

Reset to default 18

Try something like this

    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>';
发布评论

评论列表(0)

  1. 暂无评论