• Resolved Shmoo

    (@macpresss)


    Hi,

    I have this issue, where I want to change the price structure on the decimals.
    When a price in rounded like 5, 10 or maybe 17 Euro’s I don’t want to show the double zero’s behind it like, 5,00, 10,00 or 17,00.

    What I want is something very common in Europe, we replace the double zero’s with an emdash I believe it’s called. Like so, 5,, 10, or 17,.

    View post on imgur.com

    This looks way more clean than the double zero, I think I can make this myself in PHP with a check for IF == ’00’ –> replace with emdash this would leave the prices like 9,95 alone but what function do I have to look at?

    I can make some filters and functions myself but I’m just not sure where I should hook into this. Is it the get_price_html() function?

    Thanks.

    https://wordpress.org/plugins/woocommerce/

Viewing 1 replies (of 1 total)
  • Thread Starter Shmoo

    (@macpresss)

    This seems to work..

    function shmoo_price_html( $price ) {
    
    	$new_price_structure = preg_replace( '/00/', '-', $price );
    
    	return $new_price_structure;
    
    }
    add_filter( 'woocommerce_get_price_html', 'shmoo_price_html', 100, 2 );

    View post on imgur.com

    Thoughts…

    I hope this doesn’t interfere with calculating the cart (sub) totals and taxes in the end.
    That’s why I picked the get_price_html function in WooCommerce to hook into. I hope this function is only being used for showing prices in HTML format at the front-end and not for doing some (tax/shipping) calculations with.

Viewing 1 replies (of 1 total)

The topic ‘Double Zero on price decimals?’ is closed to new replies.