Hello David ,
could you help me with the riche snippet i want use ?
I'm writting the info in html/product.php
div itemscope itemtype="http://schema.org/Product">
<img itemprop="image" src="<?php print $mainProduct["image_url"]; ?>" />
<span itemprop="name"><?php print $mainProduct["search_name"]; ?></span>
<div itemprop="offers" itemscope itemtype="http://schema.org/AggregateOffer">
<span itemprop="lowPrice"><?php print $config_currencyHTML.$mainProduct["price"]; ?></span>
to <span itemprop="highPrice">???????????????????????</span>
from <span itemprop="offerCount">?????????????????????</span> sellers
1) <?php print $config_currencyHTML.$mainProduct["price"]; ?>
I Would like show first lowPrice > 0 and not = 0
2) I would like know what variable use for <span itemprop="highPrice">$.....</span>
3) I would like know what variable use for <span itemprop="offerCount">$.....</span>
Thx a lot.
Thx David it work fine ! :)
Last question
<?php
print $count;
?>
Sorry for my newbie questions :X Hope it help some other newbies.
Cheers,
Greg.
Hi Greg,
You'd need to loop through the $product["products"] array - have a go with:
<?php
$count = 0;
foreach($product["products"] as $p)
{
if ($p["price"]>0.00) $count++;
}
print $count;
?>
Cheers,
David.
--
PriceTapestry.com
Hello David
how i can display lowest and highest price for search results, and cateogies ?
Hi George,
If you first add the following code at the very top of your html/searchresults.php file:
<?php
$sql = "SELECT MIN(price) AS searchMinPrice,MAX(price) AS searchMaxPrice FROM `".$config_databaseTablePrefix."products` WHERE ".$where.$priceWhere;
database_querySelect($sql,$rows);
$searchMinPrice = $rows[0]["searchMinPrice"];
$searchMaxPrice = $rows[0]["searchMaxPrice"];
?>
You'll then have the $searchMinPrice and $searchMaxPrice variables to use to display as required, for example, anywhere after that point:
<?php
print "<p>We have found prices from ".$config_currencyHTML.$searchMinPrice." to ".$config_currencyHTML.$searchMaxPrice."</p>";
?>
This will apply to all search results pages (category results are generated by search.php in the same way as brand / merchant results) but if you need to limit to only certain queries that would be no problem - just let me know...
Cheers,
David.
--
PriceTapestry.com
nice!
and also how i can use this for pricetapestry with worpdress?
thanks again
Hi George,
To add the Search Results / Banner section, edit the plugin file pto_search.php and look for the following code at line 483:
return $html;
(this is where the HTML generated from the Search Results / Banner template is returned) and REPLACE with:
global $wpdb;
global $pto_searchWhere;
global $pto_config_databaseTablePrefix;
$sql = "SELECT MIN(price) AS searchMinPrice,MAX(price) AS searchMaxPrice FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$pto_searchWhere;
$wpdb->query($sql);
$html = str_replace("%SEARCHMINPRICE%",$wpdb->last_result[0]->searchMinPrice,$html);
$html = str_replace("%SEARCHMAXPRICE%",$wpdb->last_result[0]->searchMaxPrice,$html);
return $html;
With that in place, you'll then be able to use placeholders %SEARCHMINPRICE% and %SEARCHMAXPRICE% as required within your Search Results / Banner template (wp-admin > Settings > PriceTapestry.org)
Cheers,
David.
--
PriceTapestry.com
Hello George,
My apologies - the call to $wpdb->query was missing in the copy; corrected above.
Cheers,
David.
--
PriceTapestry.com
Hi Greg,
Re: 1/
For for lowest non-zero price, in place of:
<?php print $config_currencyHTML.$mainProduct["price"]; ?>
Use:
<?php
$lowest = 0.00;
foreach($product["products"] as $p)
{
if ($p["price"] > $lowest)
{
$lowest = $p["price"];
break;
}
}
<?php print $config_currencyHTML.$lowest; ?>
And for 2/ and 3/, have a go with:
<?php $count = count($product["products"]);
<span itemprop="highPrice"><?php print $config_currencyHTML.$product["products"][($count-1)]["price"]; ?></span>
<span itemprop="offerCount"><?php print $count; ?></span>
Cheers,
David.
--
PriceTapestry.com