Hi,
I have a problem with huge numbers of records being dropped and after browsing the forum for a while I think it might due to the required fields part of the script. Is the following example of the sort of field data I'm trying to map to the Price field causing this problem and how might I solve it?
Motorola MOTOSLVR L6 Blue on Virgin Mobile £25 18mth, with 150 mins & 150 txts a month
ie. I want to rip out the £25 and convert it to 25.00
thanks, Steve.
Hi Steve,
To handle this you would need a more complex "decimalise" function, which the routine Price Tapestry uses to extract a formatted price into its decimal equivalent. To do this, replace the tapestry_decimalise() function in includes/tapestry.php with the new version below:
<?php
function tapestry_decimalise($price)
{
$pound = strpos($price,"£");
if ($pound)
{
$break = strpos($price," ",$pound);
$price = substr($price,$pound+1,($break-$pound));
}
$price = str_replace(",",".",$price);
$price = preg_replace('/[^0-9\.]/e','',$price);
$price = sprintf("%.2f",$price);
return $price;
}
?>
The new code in this version first checks for the presence of a pound sign in the string. If found, it then extracts the portion of the string from the pound sign to the next SPACE character, and passes this modified value to the original part of the function - which would then interpret the value correctly (as 25.00 in this instance).
Hope this helps,
Cheers,
David.