Disply prices with two decimal zeroes as (,-) instead of (,00)

My goal is to display prices with two decimal zeroes as (,-) instead of (,00) for the Kr currency.

So far I’ve used the following method.

Read More

Just put this code in the theme’s functions.php file:

function remove_zeroes_from_price($price) {
    $price = str_replace(',00', ',-', $price);
    return $price;
}
add_filter('woocommerce_get_price_html', 'remove_zeroes_from_price');

and it works in all places except the amount spot and checkout pages. Does anyone have another method to apply this throughout the entire website?

Related posts

1 comment

  1. I figured out the solution please see what i used below

    function remove_zeroes_from_price($price) {
    $price = str_replace(',00', ',-', $price);
    return $price;}
    
    add_filter('woocommerce_get_price_html', 'remove_zeroes_from_price');
    add_filter('woocommerce_cart_subtotal', 'remove_zeroes_from_price');
    add_filter('woocommerce_cart_item_price', 'remove_zeroes_from_price');
    add_filter('woocommerce_cart_item_subtotal', 'remove_zeroes_from_price');
    add_filter('woocommerce_single_product_summary', 'remove_zeroes_from_price');
    add_filter('woocommerce_cart_contents_total', 'remove_zeroes_from_price');
    
    
    
    
    // Remove all currency symbols
     function sww_remove_wc_currency_symbols( $currency_symbol, $currency ) {
     $currency_symbol = '';
     return $currency_symbol;}
    add_filter('woocommerce_currency_symbol', 'sww_remove_wc_currency_symbols',     10, 2);
    add_filter('woocommerce_cart_totals_order_total_html',     'remove_zeroes_from_price');
    

Comments are closed.