Skip Navigation

[Resolved] Display Woocommerce variation stock level

This support ticket is created 4 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by christopherM-10 4 years ago.

Assisted by: Waqar.

Author
Posts
#1582905

Tell us what you are trying to do?
Display stock level of all products, including variable ones in the front end

The shortcode [wpv-post-field name='_stock'] only returns stock for the product, not the selected variation. Is there a way of returning the variation stock?

Thanks.

#1583603

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

There is no built-in feature available in Toolset to get information from WooCommerce product's variation, but you're welcome to submit this as a feature request:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

For now, this will require some custom code. You can get the IDs of all variations for a product and then get the custom field values for "_stock" custom field:
https://stackoverflow.com/questions/31232840/get-all-product-variations-of-a-product-given-its-id-in-woocommerce

Another alternative is a direct query method:
https://stackoverflow.com/questions/52857156/get-the-total-stock-of-all-variations-from-a-variable-product-in-woocommerce

For more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

regards,
Waqar

#1584313

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.