new value

cachousam

Avatar: cachousam

2012-08-07 17:30

Hello,
After creating a new variable in the file db/fr.product.php and db/fr.product.def.php all is well.
I have create a new array in template/admin/product.tpl.
The display is ok.
But how to say that this variable is numérique.For example if I write 80 I would like the script write 80.00
For the moment, when I write 80 the display is 80

Here is my code in product.tpl

<tr class="l1">
<td>
<input type="text" name="fPrice" value="$aData[fPrice]" class="inputr" size="10" /> $config[currency_symbol]
$lang[Purchaseprice]<input type="text" name="fPrice4" value="$aData[fPrice4]" class="inputr" size="10" />
Thanks

» Quick.Cart v3.x

boboo

Avatar: boboo

2012-08-07 18:12

look into common.php
the functions: normalizePrice and displayPrice

qc-plugins.kimla.de

cachousam

Avatar: cachousam

2012-08-07 18:26

Should I create a new function or write fprice4 beside fprice, because if I do this:

/**

* Return price format and display
* @return float
* @param float $fPrice
*/
function displayPrice( $fPrice ){
return $fPrice;
} // end function displayPrice

/**
* Return price format to save in database
* @return float
* @param float $fPrice
*/
function normalizePrice( $fPrice ){
//return sprintf( '%01.2f', ereg_replace( ',', '.', $fPrice ) );
return sprintf( '%01.2f', preg_replace( '/,/', '.', $fPrice ) );
} // end function normalizePrice


function displayPrice( $fPrice4 ){
return $fPrice4;
} // end function displayPrice

/**
* Return price format to save in database
* @return float
* @param float $fPrice
*/
function normalizePrice( $fPrice4 ){
//return sprintf( '%01.2f', ereg_replace( ',', '.', $fPrice4 ) );
return sprintf( '%01.2f', preg_replace( '/,/', '.', $fPrice4 ) );
} // end function normalizePrice



I have this résult :

Fatal error: Cannot redeclare displayprice() (previously declared in /web/......./wwweu/core/common.php:165) in /web/...../wwweu/core/common.php on line 182

boboo

Avatar: boboo

2012-08-07 19:39

Cachousam,
there are somewhere in core/products.php functions:
listProducts and throwProduct.
They use those normalize- & displayPrice to format the price variable's values before throwing through the tpl.

qc-plugins.kimla.de

Back to top
about us | contact