JS function for trimming zeros in price decimals doesn’t work
-
I’m trying to remove trailing zeros from rounded WooCommerce prices using the following filter/function:
add_filter( ‘woocommerce_price_trim_zeros’, ‘__return_true’ );
However, after adding this code to the Global Custom JS section, it doesn’t seem to work. I suspect the issue is that the Custom JS isn’t being applied, rather than a problem with the code itself.
Source:
https://hookturn.io/remove-trailing-zeros-woocommerce-prices/
Hello,
That code is related to the PHP, not the JS therefore of course it will not work in the custom JS area. So either put the code in the function.php file in your child theme or disable decimals via the settings of WooCommerce – https://prnt.sc/AylZ-H_XYkLf
Kind Regards
Makes sense. I’ve gone for the child theme option and it works now. Thank you.
Hello,
You’re most welcome! I’m glad to hear that using the child theme option resolved the issue. Should you need further assistance or have any other questions, feel free to reach out anytime.
Kind Regards
The topic ‘JS function for trimming zeros in price decimals doesn’t work’ is closed to new replies.