neskit
October 1, 2016, 7:44pm
1
Hello,
would you please help me remove decimal price from mywebsite
here after the code used by theme creator:
*/
function classifieds_pricing_format( $price ){
$price = number_format( $price, 2 );
$unit_position = classifieds_get_option( ‘unit_position’ );
$unit = classifieds_get_option( ‘unit’ );
$price_el = explode(‘.’, $price);
$main_price = $price_el[0];
$decimal_price = $price_el[1];
if( $unit_position == ‘back’ ){
$price_html = $main_price.'<span>.’.$decimal_price.'</span><span>’.$unit.'</span>’;
}
else{
$price_html = ‘<span>’.$unit.'</span>’.$main_price.'<span>.’.$decimal_price.'</span>’;
}
return $price_html;
}
/*
PS: I tried to replace 2 by 0 in number format; I got it removed but the decimal separator ( the point separating main price from decimal price) is still there!
neskit
October 1, 2016, 7:51pm
3
I don’t know what does it mean I know little in php and this is the code une in the theme
int()
stands for integer meaning it gets rid of decimal point
So i commented out the decimal price for you and removed it from the output string. That should completely remove it for you. I’m not sure exactly on what your after in terms of what the decimal price should be. It also can be converted to .00 or anything really.
function classifieds_pricing_format( $price )
{
$price = number_format( $price, 2 );
$unit_position = classifieds_get_option( 'unit_position' );
$unit = classifieds_get_option( 'unit' );
$price_el = explode(".", $price);
$main_price = $price_el[0];
//$decimal_price = $price_el[1];
if( $unit_position == "back" )
{
$price_html = $main_price.'<span>'.$unit.'</span>';
}
else
{
$price_html = '<span>'.$unit.'</span>'.$main_price;
}
}
neskit
October 1, 2016, 8:47pm
6
hello guys,
the problem was solved after removing the point after span:
‘.’.$decimal_price.’ ’.$unit.' ’;
}
thank you
1 Like
system
Closed
January 1, 2017, 3:47am
7
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.