Home Forums WoodMart support forum JS function for trimming zeros in price decimals doesn’t work

JS function for trimming zeros in price decimals doesn’t work

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #626772

    Jimson
    Participant

    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/

    #626876

    Luke Nielsen
    Keymaster

    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

    #627137

    Jimson
    Participant

    Makes sense. I’ve gone for the child theme option and it works now. Thank you.

    #627148

    Luke Nielsen
    Keymaster

    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

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘JS function for trimming zeros in price decimals doesn’t work’ is closed to new replies.