Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • WP 4.6 or 4.9.6? ;) Commented Jul 6, 2018 at 12:50
  • im guessing the above code goes into functions.php? Or how do I implement it? Im not building a custom theme BTW. I am trying to add it to a existing website/theme. Kind regards! Commented Jul 9, 2018 at 11:31
  • You should probably put this code in place where you want to display variants stock quantity. Commented Jul 9, 2018 at 15:58
  • Alright, so I marked your question with the bounty and the answer because I did not have time to check it the last few days and the bounty was running out and I did not know what would happen with it. I placed the code on the spot where I want to display the number and it outputs nothing. Not a single row. Commented Jul 11, 2018 at 6:49
  • I updated my answer to not work on actions. You can put wpse_306996_get_variations_stock_quantity function in functions.php file and move usage section to your template file. Remember to provide $product_id of product which has product variations. Commented Jul 11, 2018 at 7:46