Illustrations for the article

WooCommerce: How to show in-stock quantity in the order detail

Snippets, WooCommerce

Last time I was answering my client’s email about whether it’s possible to show the remaining in-stock quantity of product. And, yes, it’s possible to do so. If you need to display in-stock quantity on the order detail page in your admin area, you can use the following snippet (all credit to Roman Pamula):

Comments (8)

  1. Hello… how can i get and show a custom field or a attribute and replace stock?
    If you can help me… Thanks you!!

  2. Hello,

    Thank you indeed for the snippet.
    Can you make to display stocks for variable products?

    Regards.

  3. how to make this work on PHP 8.0?

    It works well on PHP 7.4 but not PHP 8.0.

    When switch to PHP 8.0 it will show the error below:

    There has been a critical error on this website. Please check your site admin email inbox for instructions.

    Learn more about troubleshooting WordPress.

  4. Hi, and thanks for this. Work perfectly!

    – I would also like to see the availability for variable products. Let’s say my shop sells T-shirts with attributes White (5 in stock), Blue (8 in stock) and Black (10 in stock).

    My customer have ordered 1 x T-shirt White.

    In the product-list of the order details I would like to see that this product now have 4 in stock.

    What would be AWESOME as well is to automatically mark the full product line in red if the product is in negative stock. Let’s say a product is set to sell even if out of stock, and the stock is -4. When looking at the product list in the order details, the entire line is now set to red color, so it sticks out.

    It would be very beneficial to the guys picking and packing.

    Possible to do?

Leave a Reply

Your email address will not be published. Required fields are marked *