• Resolved Jose

    (@josefaarseth)


    One of the stores I manage is currently facing a bugthat is not solved yet by WooCommerce, regarding rounding prices introduced without tax. So far one of the temp fixes that work is changing the whole store to 4 decimals to improve accuracy. Now the problem is that some new clients seem to believe our prices are in another currency other than USD because of the 6 digits that get presented (19.998). I’m wondering if there is a way to format the output of woocommerce_get_price_html using something like number_format. I’m a bit lost because the output of this is escaped html to style the price, so something like this

    `add_filter( ‘woocommerce_get_price_html’, ’rounded_price_html’, 100, 2 );
    function rounded_price_html( $price, $product ){
    return number_format( $price, 2, ‘,’, ‘.’);
    }`

    would not work. So basically what I’m asking is, is there any way I can format the price of this function without interfering with the HTML? This should only affect the front end as we don’t care about the four digits in the back. Creating something using JS is not an option as our theme is AJAX based and that would just create more work

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Hi there 👋

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers.

    hello

    If you just wanna do that you can do it by woocommerce settings. Just go to admin dashboard->woocomerce->setting->Genrak tab look for currency option and set Number of decimals.

    thanks and regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Format decimals of get_price_html’ is closed to new replies.