I have created an optional field 'size' and I noticed some merchants have multiple sizes in their size fields e.g.: "40,42,44"
Is there a way so that I can split it up. So that the same clothing piece can be found for size 40 or 42 or 44?
Hi,
I get Warning: usort() expects parameter 1 to be array, object given in /.../wp-content/plugins/pto/pto_search.php on line 1021
Fatal error: Cannot use object of type stdClass as array in /.../wp-content/plugins/pto/pto_search.php on line 1027
Probably I put the code in the wrong place?
Here a snippet of the changes:
{code saved}
BTW: I changed size to maat as this is the fieldname in the database
Hi Marco,
If you do have any merchants that use an alternative separator the advice on the Price Tapestry forum from your post here would still be required, so that multiple value fields are all comma separated.
Then in the modified pto_search.php (with custom filters) look for the following code at line 112:
$priceWhere .= " AND ".$filter." = '".$wpdb->escape($$filterVar)."' ";
...and REPLACE with:
if ($filter=="size")
{
$priceWhere .= " AND ".$filter." LIKE '%".$wpdb->escape($$filterVar)."%' ";
}
else
{
$priceWhere .= " AND ".$filter." = '".$wpdb->escape($$filterVar)."' ";
}
Then to create a single drop down box for the filter from the comma separated values; look for the following code at line 977 (add this before the previous mod to sort size according to weighted preference)
$html_filter = "";
...and REPLACE with:
$html_filter = "";
if ($filter=="size")
{
$new_last_result = array();
for($i=0;$i<$numRows;$i++)
{
$sizes = explode(",",$wpdb->last_result[$i]->size);
foreach($sizes as $size)
{
$size = trim($size);
if ($size)
{
$new_last_result[$size] = (object)array("size"=>$size);
}
}
}
ksort($new_last_result);
$numRows = count($new_last_result);
$wpdb->last_result = (object)$new_last_result;
}
Cheers,
David.
--
PriceTapestry.com