Show Trailing Zeroes on WooCommerce Products Prices

From WooCommerce 2.1 (2.1.3 to be precise) the trailing zeros has been removed from the products prices. This has been implemented using a function (woocommerce_price_trim_zeros) which removes the trailing zeros. Not, this make senses in many ways. Then again if you want to have the zeros to be displayed, there are simple solution available.

add_filter('woocommerce_price_trim_zeros','display_trailing_zeros', 10, 1);
function display_trailing_zeros($trim){
   return false; }

In this snippet all we are doing is adding a filter with the function which returns no value forcing WC to follow the traditional path of displaying zeros. This is as simple as it can get. All you need to do now is to simply copy and paste the snippet mentioned above on your theme’s functions.php age and update it. You should be good to go.

Reference: add_filter.

Today In History



Leave a Reply

Note: Convet HTML, PHP, JavaScripts from HTMLify, before posting from comment section.
License: By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution. Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.