how to change price format

rikkibr

No avatar

2006-07-04 19:03

Hello

How do I get rid of the .00 decimals in the price?

I want to take away ".00" and put in ",-" instead

Thanks
rikkibr

rikkibr

No avatar

2006-07-04 20:33

I did this change in other.php but this only takes the decimals off when the product is in the cart, decimals are still on in the product pages

function tPrice( $fPrice ){
return sprintf( '%01.0f', $fPrice );
} // end function tPrice

treewood (OpenSolution)

Avatar: treewood

2006-07-04 20:53

rikkibr - it will take some work:
1. edit core/products.php, function throwProductsData() and before line where is $content .= $tpl->tbHtml( $sFile, 'LIST_LIST' ); add one line:

$aList['fPrice'] = ereg_replace'.00'',-'$aList['fPrice'] );


2. edit actions_client/products.php and before line where is $content .= $tpl->tbHtml( $sFile, 'SHOW' ); add one line:

$aData['fPrice'] = ereg_replace'.00'',-'$aData['fPrice'] );


if You want to change it in orders it will be long story ... You need to change core/orders.php, function listBasket() after actions_client/orders.php and js functions js/ordersCouriers.js. we can do it for You if You want. contact with us using contact form

szpeti

No avatar

2008-05-13 18:18

Hi!

How can I apply these changes in v3.0?

beholder

Avatar: beholder

2008-05-13 21:47

>>szpeti
it's in documentation>tips, DAFS

QC v. 3.0 final

beholder

Avatar: beholder

2008-05-13 21:52

oops, sorry szpeti,

I thought you were mentioning the decimals delimiter, not the .00 replacement with ,-

QC v. 3.0 final

beholder

Avatar: beholder

2008-05-13 22:37

>>Szpeti>> Change price format to display ",-" in QC 3.0:


1. core/common.js, changePriceFormat() :
var sDecimalSeparator = ',';
next change:
sPrice = sPriceFull+''+sDecimalSeparator+''+aPrice[1];
to:
if ( aPrice[1] == 0 )
sPrice = sPriceFull+",-";
else
sPrice = sPriceFull+''+sDecimalSeparator+''+aPrice[1];


2. core/common.php:
function displayPrice( $fPrice){
if ( intval($fPrice) == $fPrice ) return number_format( $fPrice,0,'', '' ).',-';
else return number_format( $fPrice, 2, ',', '' );
} // end function displayPrice


3. templates/orders_form.tpl:
<fieldset id="deliveryAndPayment">
<legend>$lang[Delivery_and_payment] (prices are in $config[currency_symbol])</legend>
$sPaymentCarriers
</fieldset>

<td id="carrierCost">
0,-
</td>

QC v. 3.0 final

szpeti

No avatar

2008-05-14 16:45

It's working! Thak you so much! :)

rustam

No avatar

2008-05-20 20:50

There is more elegant way to change currency display format in V3.0

in core/common.php in function displayPrice replace:

return $fPrice;

with this

return ereg_replace( '.00', '-', $fPrice );

beholder

Avatar: beholder

2008-05-20 23:37

>>Rustam>>
yes, it is a bit more ellegant,
but you need to use my code for core/common.js to display the price well on the orders form page, when the user clicks the couriers-payments table.

beholder

Avatar: beholder

2008-05-21 03:42

this one is gold, along with the other necessary changes:

function displayPrice( $fPrice){
return ereg_replace( ',00', ',-', number_format( $fPrice, 2, ',', '' ) );
} // end function displayPrice

beholder

Avatar: beholder

2008-05-21 04:00

actually, str_replace() would work faster in this case, as we don't need to deal with regular expressions here...

roniwahyu

No avatar

2008-08-10 11:05

thanks master,

In Indonesia, we use IDR with Rp. symbol. And using coma (,) for thousand separator and that symbol (,-). so the result is

Rp. 1.000.000,-,

so would you like to help me?

thanks.

Roniwahyu

beholder

Avatar: beholder

2008-08-10 23:19

roniwahyu>> This is very basic question, based on the information already posted. Next do that little research yourself.

Change price format to display "1.000.000,-" in QC 3.0:

1. core/common.js, changePriceFormat() :
var sDecimalSeparator = ',';
var sThousandSeparator = '.';

next change:
sPrice = sPriceFull+''+sDecimalSeparator+''+aPrice[1];
to:
if ( aPrice[1] == 0 )
sPrice = sPriceFull+",-";
else
sPrice = sPriceFull+''+sDecimalSeparator+''+aPrice[1];


2. core/common.php:
Function displayPrice( $fPrice){
return str_replace( ',00', ',-', number_format( $fPrice, 2, ',', '.' ) );
} // end function displayPrice


3. templates/orders_form.tpl:
<fieldset id="deliveryAndPayment">
<legend>$lang[Delivery_and_payment] (prices are in $config[currency_symbol])</legend>
$sPaymentCarriers
</fieldset>

<td id="carrierCost">
0,-
</td>

QC v3.x

klubsukses

No avatar

2008-08-17 09:16

###roniwahyu
Edit file edit templates/products_default.tpl, templates/pages_default.tpl

<strong>$aData[sPrice]</strong><span>$config[currency_symbol]</span>

pindahkan posisi nya jadi

<span>$config[currency_symbol]</span><strong>$aData[sPrice]</strong>

www.klubsukses.com

Dudus

Avatar: Dudus

2012-11-15 13:33

Hi!

I have same problem in v3.5.

I want to take away ".00" and put in ",-" instead.

I changed:

1. core/common.js, changePriceFormat() :
var sDecimalSeparator = ',';
next change:
sPrice = sPriceFull+''+sDecimalSeparator+''+aPrice[1];
to:
if ( aPrice[1] == 0 )
sPrice = sPriceFull+",-";
else
sPrice = sPriceFull+''+sDecimalSeparator+''+aPrice[1];


2. core/common.php:
function displayPrice( $fPrice){
if ( intval($fPrice) == $fPrice ) return number_format( $fPrice,0,'', '' ).',-';
else return number_format( $fPrice, 2, ',', '' );
} // end function displayPrice


3. templates/orders_form.tpl:
<fieldset id="deliveryAndPayment">
<legend>$lang[Delivery_and_payment] (prices are in $config[currency_symbol])</legend>
$sPaymentCarriers
</fieldset>

<td id="carrierCost">
0,-
</td>

All working, but if my product have attributes, then the price change to: 0,-


Please help, thanks: Dudus

CzM

Avatar: CzM

2013-01-06 10:22

I'd like to take off .00 in QC5.1. Any solution for it?

Back to top
about us | contact