Hi David
I have worked through this thread http://www.pricetapestry.org/node/265 to add more filters. It appears from the line number references that the coding on pto and pto_search have changed since you helped Henk.
Although there is already a minPrice and maxPrice functionality, I would like to duplicate this functionality so that a user filter on minDiscount and maxDiscount as well.
I have looked through emails from 2009 but the pto upgrade is so different to the stand alone PT installation.
How would I go about this with the pto installation?
Regards
Richard
Ps have a good weekend!
Hi David
Many thanks, it works a treat :)
How could I keep the minDiscount/maxDiscount variables to persist when using the search filter widget?
For example, once I have user click on link that searches for min/max discount, it would be nice if user could refine search using existing filter widget. At the moment the widget ignores the min/max discount and returns all results again.
Regards
Richard
Hi Richard,
Ah - to persist the variables through the filter form, in pto_search.php, look for the following code at line 923:
$html = str_replace("%ACTION%",get_bloginfo('url').$pto_config_permalink,$html);
...and REPLACE with:
$html = str_replace("%ACTION%",get_bloginfo('url').$pto_config_permalink,$html);
global $pto_minDiscount;
global $pto_maxDiscount;
$html = str_replace("</form>","<input type='hidden' name='pto_minDiscount' value='".$pto_minDiscount."' /></form>",$html);
$html = str_replace("</form>","<input type='hidden' name='pto_maxDiscount' value='".$pto_maxDiscount."' /></form>",$html);
Cheers,
David.
--
PriceTapestry.com
Hi Richard,
For PriceTapestry.org version 2, to replicate minPrice/maxPrice for minDiscount/maxDiscount first in pto.php look for the following code at line 573:
array_push($vars, 'pto_merchantFilter');
...and REPLACE with:
array_push($vars, 'pto_minDiscount');
array_push($vars, 'pto_maxDiscount');
array_push($vars, 'pto_merchantFilter');
Then in pto_search.php look for the following code at line 82:
if ($pto_merchantFilter)
...REPLACE with:
global $pto_minDiscount;
global $pto_maxDiscount;
if (isset($pto_minDiscount) && $pto_minDiscount)
{
$pto_minDiscount = sprintf("%.2f",$pto_minDiscount);
}
else
{
$pto_minDiscount = "";
}
if (isset($pto_maxDiscount) && $pto_maxDiscount)
{
$pto_maxDiscount = sprintf("%.2f",$pto_maxDiscount);
}
else
{
$pto_maxDiscount = "";
}
if ($pto_minDiscount || $pto_maxDiscount)
{
if ($pto_minDiscount && $pto_maxDiscount)
{
$priceWhere .= " AND price BETWEEN '".$pto_minDiscount."' AND '".$pto_maxDiscount."' ";
}
elseif ($pto_minDiscount)
{
$priceWhere .= " AND price > '".$pto_minDiscount."' ";
}
elseif ($pto_maxDiscount)
{
$priceWhere .= " AND price < '".$pto_maxDiscount."' ";
}
}
if ($pto_merchantFilter)
Then the following code at line 446:
if ($pto_merchantFilter) $sortBaseHREF .= "&pto_merchantFilter=".urlencode($pto_merchantFilter);
...and REPLACE with:
global $pto_minDiscount;
global $pto_maxDiscount;
if ($pto_minDiscount) $sortBaseHREF .= "&pto_minDiscount=".urlencode($pto_minDiscount);
if ($pto_maxDiscount) $sortBaseHREF .= "&pto_maxDiscount=".urlencode($pto_maxDiscount);
if ($pto_merchantFilter) $sortBaseHREF .= "&pto_merchantFilter=".urlencode($pto_merchantFilter);
And finally the following code at line 664:
global $pto_minDiscount;
global $pto_maxDiscount;
if ($pto_minDiscount) $navigationBaseHREF .= "&pto_minDiscount=".urlencode($pto_minDiscount);
if ($pto_maxDiscount) $navigationBaseHREF .= "&pto_maxDiscount=".urlencode($pto_maxDiscount);
if ($pto_merchantFilter) $navigationBaseHREF .= "&pto_merchantFilter=".urlencode($pto_merchantFilter);
Hope this helps!
Cheers,
David.
--
PriceTapestry.com