You are here:  » importing price , instead of .


importing price , instead of .

Submitted by henk on Wed, 2006-03-29 21:52 in

What can i do about a price what is written in 1,00 instead of 1.00 if i pars it the price is 100.00 :)

THX

HEnk

Submitted by support on Wed, 2006-03-29 22:12

Hi Henk,

This will require a mod to the decimalise function, which I think is worth incorporating into the distribution, so i'll do that. In the file includes/tapestry.php, alter the function:

function tapestry_decimalise($price)
{
  $price = preg_replace('/[^0-9\.]/e','',$price);
  $price = sprintf("%.2f",$price);
  return $price;
}

...so that it does a search and replace on "," for ".", and allows "," through the filter:

function tapestry_decimalise($price)
{
  $price = str_replace(",",".",$price);
  $price = preg_replace('/[^0-9\.]/e','',$price);
  $price = sprintf("%.2f",$price);
  return $price;
}

..it should then work...

Submitted by support on Wed, 2006-03-29 22:46

Correction - there was no need for the comma in the regular expression; but it shouldn't have made any difference.