Hello David
A new feed I'm importing has a price field like 340 - 600
Would there be a way to add a filter that deleted everything after the 340
Thanks
Mally
Hi Mally,
The easiest thing to do would be to fix this within the tapestry_decimalise() function in includes/tapestry.php, currently:
function tapestry_decimalise($price) { $price = str_replace(",",".",$price); $price = preg_replace('/[^0-9\.]/e','',$price); $price = sprintf("%.2f",$price); return $price; }
Try changing this as follows:
function tapestry_decimalise($price) { $price = str_replace(",",".",$price); if (strpos($price," ")) { $price = substr($price,0,strpos($price," ")); } $price = preg_replace('/[^0-9\.]/e','',$price); $price = sprintf("%.2f",$price); return $price; }
The substr() will ensure that only characters up to any SPACE characeter are included...
Cheers, David.
excellent, works well, Thanks!
©2006-2025 IAAI Software | Contact Us | Privacy Policy
Hi Mally,
The easiest thing to do would be to fix this within the tapestry_decimalise() function in includes/tapestry.php, currently:
function tapestry_decimalise($price)
{
$price = str_replace(",",".",$price);
$price = preg_replace('/[^0-9\.]/e','',$price);
$price = sprintf("%.2f",$price);
return $price;
}
Try changing this as follows:
function tapestry_decimalise($price)
{
$price = str_replace(",",".",$price);
if (strpos($price," "))
{
$price = substr($price,0,strpos($price," "));
}
$price = preg_replace('/[^0-9\.]/e','',$price);
$price = sprintf("%.2f",$price);
return $price;
}
The substr() will ensure that only characters up to any SPACE characeter are included...
Cheers,
David.