Tell us what you are trying to do?
I'm trying to display the stock level of Woocommerce products to Admins and Shop Managers in the front-end
Is there any documentation that you are following?
No
Is there a similar example that we can see?
No
What is the link to your site?
hidden link (but you wouldn't see it if logged out)
I'm using the shortcode [wpv-post-field name='_stock'] placed in a Astra pro custom layout on a web hook into product pages, conditionally on user role. It works fine, except that the stock level is output with 6 decimal places, where the stock will always be a whole number. Can I format this field to show 0 decimal places?
Thanks.
wpv-post-field will output whatever is stored in the Field, it is not very dynamic in reading third party input types.
I did not know WooCommerce stores that value with decimals, it makes poor sense, as you can't have 1.5 products in stock.
In fact, when I use this locally, on a WooCommerce site, I always get full integers.
Maybe you have some plugin or custom code in place that allows decimalizing in stock amounts?
In that case, it will make sense not to "change" that, as that code or plugin will have a reason to output decimals
Although I am pretty sure this will not work with WooCommerce native behaviours, there are many checks for "1 or 0", as opposed to "greater than 0" which would be required in a decimalized stock quantity.
Yes, that makes sense. I have identified a plugin that is updating stock. After it does so, this happens, but I can't see the extra decimal places anywhere else. I'm checking with the developer. I hope they are helpful.
Thanks.