Voeg deze code toe aan functions.php van je thema of Code Snippets.


//Create sup price
add_filter( 'formatted_woocommerce_price', 'set_woo_decimal_price', 10, 5 );
function set_woo_decimal_price( $formatted_price, $price, $decimal_places, $decimal_separator, $thousand_separator ) {
//Display normal format in backend
if(!is_admin()){

//Format the price
$unit = number_format( intval( $price ), 0, $decimal_separator, $thousand_separator );
$decimal = sprintf( '%02d', ( $price - intval( $price ) ) * 1000 );

//if statement, Price may get rounded wrong otherwise
if(strlen($decimal)!==2){
$correct_dec = round($decimal,-1)/10;
}
else{
$correct_dec = $decimal;
}
//return new formated price for frontend
return $unit . $decimal_separator. '' .$correct_dec . '';
}

else{
// return normal format in admin
return $formatted_price;
}
}


Voeg eventueel dit nog toe aan je stylesheet.


//Create sup price
add_filter( 'formatted_woocommerce_price', 'set_woo_decimal_price', 10, 5 );
function set_woo_decimal_price( $formatted_price, $price, $decimal_places, $decimal_separator, $thousand_separator ) {
//Display normal format in backend
if(!is_admin()){

//Format the price
$unit = number_format( intval( $price ), 0, $decimal_separator, $thousand_separator );
$decimal = sprintf( '%02d', ( $price - intval( $price ) ) * 1000 );

//if statement, Price may get rounded wrong otherwise
if(strlen($decimal)!==2){
$correct_dec = round($decimal,-1)/10;
}
else{
$correct_dec = $decimal;
}
//return new formated price for frontend
return $unit . $decimal_separator. '' .$correct_dec . '';
}

else{
// return normal format in admin
return $formatted_price;
}
}