You are here:  » Filter By Price

Support Forum



Filter By Price

Submitted by brentmitchell on Wed, 2011-09-07 18:05 in

Hi David,

I have set up a global filter to set the minimum price an item needs to be to be imported, but I'd like to take that further within the feed filtering...I'd like to be able to filter numerous feeds by a different price.

I'm using the Drop Record and setting it to Price, but I don't know how to list it in the field...I've tried numerous entries, but still not filtering anything. How do you list it?

(<100.00)
<100.00

Please let me know...thanks for all your help!

Submitted by support on Thu, 2011-09-08 07:33

Hi Brent,

Rather than the global filter modification in includes/admin.php, here's a new Drop by Price Range filter. Paste the code into the end of your includes/filter.php, just before the closing PHP tag:

  /*************************************************/
  /* Price Range */
  /*************************************************/
  $filter_names["priceRange"] = "Price Range";
  function filter_priceRangeConfigure($filter_data)
  {
    print "Min:<br />";
    print "<input type='text' size='40' name='min' value='".widget_safe($filter_data["min"])."' />";
    print "Max:<br />";
    print "<input type='text' size='40' name='max' value='".widget_safe($filter_data["max"])."' />";
  }
  function filter_priceRangeValidate($filter_data)
  {
  }
  function filter_priceRangeExec($filter_data,$text)
  {
    global $filter_dropRecordFlag;
    if($filter_dropRecordFlag)
    {
      return $text;
    }
    $test = tapestry_decimalise($text);
    if ($filter_data["min"])
    {
      $filter_dropRecordFlag = ($test < tapestry_decimalise($filter_data["min"]));
    }
    if ($filter_data["max"])
    {
      $filter_dropRecordFlag = ($test > tapestry_decimalise($filter_data["max"]));
    }
    return $text;
  }

Add the new filter to the Price field for a feed; and if you only want to filter by min price leave the max price field empty, and vice versa...

Cheers,
David.
--
PriceTapestry.com

Submitted by brentmitchell on Thu, 2011-09-08 18:55

You rock David!