Sell ​​out prices with two decimal zeros as (, -) instead of (, 00)

My goal is to display prices with two decimal zeros as ( ,-

) instead of ( ,00

) for the Kr currency.

So far I have used the following method.

Just put this code in your 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 point count and control pages. Does anyone have any other way to apply this across the entire website?

+3


source to share


1 answer


I figured out the solution by looking at 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');

      

0


source







All Articles