I have the stock level displayed on my site as per this support ticket: https://toolset.com/forums/topic/unable-to-display-stock-quantity/
However, the stock level is showing up as 13.000000 - how can I amend the shortcode to only show 13. (Shortcode: [wpv-post-field name='_stock'] )
Kind Regards,
Orla
_stock will return you the stock you have of the product as saved by WooCommerce.
Do you have 13k of the product in stock?
If so the display is correct. You cannot alter that - but you could write a custom ShortCode that somehow alters the value of stock to a less long cypher.
But Toolset cannot help with this, it requires custom coding.
No there were 13 in stock. The formatting was showing 13.00000
Now I am having a bigger issue but I will post in a separate support request as it is complicated.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Orla,
Perhaps you can try this below.
// Add Shortcode
function wp_cust_round( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'num' => '',
),
$atts
);
return round($atts['num']);
}
add_shortcode( 'wp_cust_round', 'wp_cust_round' );
I wrote this custom code to round your number to the nearest whole number.
Usage is [wp_cust_round num="[wpv-post-field name='_stock']"]
Add the custom shortcode to your toolset custom code settings in Toolset -> Settings -> Custom Coding and activate it.
Please let me know if this helps.
Thanks,
Shane