Skip Navigation

[Closed] Trailing Zeros

This support ticket is created 10 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/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 10 years ago.

Assigned support staff: Luo Yang.

Author
Posts
#37151

I am using Types and Views in conjunction with WooCommerce plugin. I am using Views to create custom lists of products that I filter by custom taxonomies to use for a landing page... very handy!!! The ONLY complaint I have is that WP-VIEWS is stripping the trailing zero from the field "_price", which is the database id for WooCommerce's price field. Again, everything is working perfectly except the trailing zeros are removed when page is rendered (i.e.: $8.50" becomes "$8.5", or $8.00" becomes "$8". I have disabled the strip trailing zero function in WooCommerce admin, and WooCommerce works right... just not the field rendered thru WP-Views. Any thoughts?

#37249

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hi Russell,

Views outpot the "_price" field value stored in database. I suggest you create a WP shortcode for it, like this:
1) add codes in your theme/functions.php
function my_price_func( $atts ) {
extract( shortcode_atts( array(
'price' => '',
), $atts ) );
$res= here put PHP codes to format your price value;
return $res;
}
add_shortcode( 'my-price', 'my_price_func' );

2)Then modify your views content, like this:
[my-price price="8.5"]

More help: http://codex.wordpress.org/Shortcode_APIv

Regards
Luo

The topic ‘[Closed] Trailing Zeros’ is closed to new replies.