When using Donation Platform for WooCommerce, you might want to simplify the display of prices by removing trailing zeros. By default, WooCommerce shows two decimal places, but you can easily adjust this to suit your needs.
Steps to Remove Trailing Zeros
Use the woocommerce_price_trim_zeros
Filter
If you want to completely remove trailing zeros (for example, display $10 instead of $10.00), you can use the built-in woocommerce_price_trim_zeros
filter. Here’s a snippet of code to achieve this: add_filter( 'woocommerce_price_trim_zeros', '__return_true' );
You can add this code to your theme’s functions.php
file, but it’s recommended to use the Code Snippets plugin to safely and conveniently manage custom code.
/**
* Trim zeros in price decimals
**/
add_filter( 'woocommerce_price_trim_zeros', '__return_true' );
With these steps, you can easily manage how your prices appear to users, ensuring a cleaner, more concise display on your WooCommerce store.