Title: Get variation stock quantity
Last modified: June 25, 2018

---

# Get variation stock quantity

 *  Resolved [robbertcognito](https://wordpress.org/support/users/robbertcognito/)
 * (@robbertcognito)
 * [8 years ago](https://wordpress.org/support/topic/get-variation-stock-quantity/)
 * Hi,
 * On a website im working on I have the ability to request a variation description
   by the following code:
    <div class=”woocommerce-variation-description”>{{{ data.
   variation.variation_description }}}</div>
 * I need the variation stock quantity but I cant seem to figure out what to use
   for it.
 * I was thinking:
    <div class=”woocommerce-variation-stock”>{{{ data.variation.
   variable_stock}}}</div>
 * But the above displays nothing.
 * I have searched google but only massive amounts of code come up which I really
   do not want to use.
 * Kind regards,
    Robbert

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Support [Ryan Ray](https://wordpress.org/support/users/ryanr14/)
 * (@ryanr14)
 * [7 years, 12 months ago](https://wordpress.org/support/topic/get-variation-stock-quantity/#post-10434054)
 * Hi Robbert,
 * It doesn’t appear there is a way to get quantity via javascript, in core I only
   see description, price, and availability.
 * I think you’ll have to resort to good ol’ fashioned PHP to get the stock.
 *  Thread Starter [robbertcognito](https://wordpress.org/support/users/robbertcognito/)
 * (@robbertcognito)
 * [7 years, 12 months ago](https://wordpress.org/support/topic/get-variation-stock-quantity/#post-10435297)
 * Do you have any recommendations on how to do this? There are so many ways to 
   do it ranging from 2 lines of code to 30 so I do not know what is the best aproach
   for this.
 * Kind regards,
    Robbert
 *  [jessepearson](https://wordpress.org/support/users/jessepearson/)
 * (@jessepearson)
 * Automattic Happiness Engineer
 * [7 years, 12 months ago](https://wordpress.org/support/topic/get-variation-stock-quantity/#post-10437766)
 * [@robbertcognito](https://wordpress.org/support/users/robbertcognito/) Try using
   this:
 * `{{{ data.variation.max_qty}}}`
 * It is set here:
    [https://github.com/woocommerce/woocommerce/blob/3.4.3/includes/class-wc-product-variable.php#L343](https://github.com/woocommerce/woocommerce/blob/3.4.3/includes/class-wc-product-variable.php#L343)
 * Which calls this:
    [https://github.com/woocommerce/woocommerce/blob/3.4.3/includes/abstracts/abstract-wc-product.php#L1745-L1753](https://github.com/woocommerce/woocommerce/blob/3.4.3/includes/abstracts/abstract-wc-product.php#L1745-L1753)
 * As long as there’s a positive amount, you should get the quantity.
 *  Thread Starter [robbertcognito](https://wordpress.org/support/users/robbertcognito/)
 * (@robbertcognito)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/get-variation-stock-quantity/#post-10453646)
 * Hey Jesse!
 * Sorry for the late response, I only work 3 days a week. I will try your method
   as soon as I get back to the project 🙂 Ill let you know if it worked!
 * Kind regards,
    Robbert
 *  Thread Starter [robbertcognito](https://wordpress.org/support/users/robbertcognito/)
 * (@robbertcognito)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/get-variation-stock-quantity/#post-10454038)
 * > [@robbertcognito](https://wordpress.org/support/users/robbertcognito/) Try 
   > using this:
   > {{{ data.variation.max_qty}}}
   > It is set here:
   >  [https://github.com/woocommerce/woocommerce/blob/3.4.3/includes/class-wc-product-variable.php#L343](https://github.com/woocommerce/woocommerce/blob/3.4.3/includes/class-wc-product-variable.php#L343)
   > Which calls this:
   >  [https://github.com/woocommerce/woocommerce/blob/3.4.3/includes/abstracts/abstract-wc-product.php#L1745-L1753](https://github.com/woocommerce/woocommerce/blob/3.4.3/includes/abstracts/abstract-wc-product.php#L1745-L1753)
   > As long as there’s a positive amount, you should get the quantity.
 * I have tried it in different files but am unable to get any value out of it. 
   I checked if the files you mentioned exist and if the code you highlighted were
   there and it was all there.
 * Where do you suggest I put this code?
 * Kind regards,
    Robbert
 *  Thread Starter [robbertcognito](https://wordpress.org/support/users/robbertcognito/)
 * (@robbertcognito)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/get-variation-stock-quantity/#post-10457483)
 * I think I found the spot where to put it but it outputs nothing. It just gives
   me an empty div 🙁
 *  [con](https://wordpress.org/support/users/conschneider/)
 * (@conschneider)
 * Engineer
 * [7 years, 11 months ago](https://wordpress.org/support/topic/get-variation-stock-quantity/#post-10488228)
 * Hi again,
 * How about this: [https://stackoverflow.com/questions/30514596/how-get-variations-stock-quantity-woocommerce](https://stackoverflow.com/questions/30514596/how-get-variations-stock-quantity-woocommerce)
   
   They suggest several ways of getting the variation stock quantity.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Get variation stock quantity’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 7 replies
 * 4 participants
 * Last reply from: [con](https://wordpress.org/support/users/conschneider/)
 * Last activity: [7 years, 11 months ago](https://wordpress.org/support/topic/get-variation-stock-quantity/#post-10488228)
 * Status: resolved