M
M
makaromax232019-11-12 11:14:03
WordPress
makaromax23, 2019-11-12 11:14:03

How to display information about the availability of a quantity of goods in woocomerce?

Good afternoon, you need to display information about the number of goods in stock. Thus, if there is less than 50 goods, we display its quantity. If more than 50 we write "more than 50 pcs." if 0 then we write "under the order". How to do it? I tried to display below but it does not display). Displays just how many items are in stock
5dca6caf41c6a330688315.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lord_Dantes, 2019-11-12
@Lord_Dantes

is_in_stock is a boolean function, i.e. it returns true/false values

if ( $product->is_in_stock() ) {
        echo '<div class="stock" >' . $product->get_stock_quantity() . ' в наличии</div>';
    } else {
        echo '<div class="out-of-stock" >Нет в наличии</div>';
    }

UPD, I can’t say for sure, but you can take out the number of products separately and then compare them in if
The function that displays the number$product->get_stock_quantity()

M
makaromax23, 2019-11-12
@makaromax23

5dca6bf212e9f139870816.png
And how then to withdraw? please help i am newbie

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question