Product Price
Hi David
Is it possible to show the pre voucher price and the with voucher price on the products page. I have the site configured for $config_useVoucherCodes = 1;
Thanks
Chris
Thanks David
That was great.
I've been reading through the forum looking for help on showing the correct merchant logo in the search results page but not found much. I am trying to get the lowest priced merchant logo to show if more than 1 merchant is selling the product. At the moment the result shows non lowest merchant.
Chris
Hi Chris,
That's happening because the search results are generated by a summary query; which means that the product record from which the non-summary fields are returned is undefined (although it will be consistent until the next import). What's needed is a re-query at the top of html/searchresults.php to update the merchant field in in each row with the cheapest merchant. To do this, add the following code to the top of html/searchresults.php
<?php
foreach($searchresults["products"] as $k => $product)
{
$sql = "SELECT merchant FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($product["name"])."' ORDER BY price LIMIT 1";
database_querySelect($sql,$rows);
$searchresults["products"][$k]["merchant"] = $rows[0]["merchant"];
}
?>
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Brilliant, thanks.
Can that be extended so that the deep link to merchant site would work also.
<?php
if (file_exists("logos/".$product["merchant"])):
print "<div class='search-result-logo'>";
print "<a target='_blank' title='View this item on the ".$product["merchant"]." website' href='".tapestry_buyURL($product)."'>";
print "<img alt='View this item on the ".$product["merchant"]." website' style='border: 0px' height='31' src='".$config_baseHREF."logos/".$product["merchant"]."' width='88' />";
print "</a>";
print "</div>";
endif;
?>
Hi Chris,
Sure, you can extend the re-query to include id and buy_url which are the only other fields required by tapestry_buyURL() - have a go with:
<?php
foreach($searchresults["products"] as $k => $product)
{
$sql = "SELECT merchant,id,buy_url FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($product["name"])."' ORDER BY price LIMIT 1";
database_querySelect($sql,$rows);
$searchresults["products"][$k]["merchant"] = $rows[0]["merchant"];
$searchresults["products"][$k]["id"] = $rows[0]["id"];
$searchresults["products"][$k]["buy_url"] = $rows[0]["buy_url"];
}
?>
Cheers,
David.
--
PriceTapestry.com
Hi Chris,
Sure- just a little modification required. In products.php look for the following code at line 18:
if ($config_useVoucherCodes === 1)...and REPLACE with:
foreach($rows as $k => $row){
$rows[$k]["normalprice"] = $row["price"];
}
if ($config_useVoucherCodes === 1)
With that in place, $product["normalprice"] will be available wherever there is product variable in context; e.g $mainProduct["normalprice"] in html/product.php or $product["normalprice"] in html/prices.php.
For example, if you wanted to show the normal price with a strikethrough where the discounted price is less, in html/prices.php look for where the price is displayed by this code within line 13:
<strong><?php print $config_currencyHTML.$product["price"]; ?></strong>...and REPLACE with:
<?php print ($product["normalprice"]!=$product["price"]?"<span style='text-decoration:line-through;'>".$config_currencyHTML.$product["normalprice"]."</span> ":"")?><strong><?php print $config_currencyHTML.$product["price"]; ?></strong>
Hope this helps!
Cheers,
David.
--
PriceTapestry.com