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.
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
My issue is resolved now. Thank you!