You are here:  » Price field has a between £123 - £456

Support Forum



Price field has a between £123 - £456

Submitted by mally on Tue, 2008-05-20 21:09 in

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

Submitted by support on Wed, 2008-05-21 09:06

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.

Submitted by mally on Wed, 2008-05-21 19:25

excellent, works well, Thanks!

Mally