Hi David,
On one of my niche sites I would like to display a ‘best price’ (and also maybe the retailer offering that price) on each of my product review pages. Below the ‘best price’ I plan to provide a direct link to allow the user to jump to the full PT price comparison for that particular product. The current site structure is:
>Home Page
>>Product Review Pages (where I would like to display best price)
>>>Product Price Comparison Page
Please could you tell me if there is a simple way to display the ‘best price’ (and possibly the retailer) in a page preceding the full price comparison page?
Thanks in advance.
Regards
Chris
Hi David,
Thanks as always for your quick reply. I pasted the code below into a file on my site to test it and the error below was displayed:
Fatal error: Call to undefined function database_safe() in {link saved} on line 3
I'm new to php (but learning quickly.. I hope!) so wondered if you could suggest how I might resolve this? as I'm not sure if I'm missing something obvious or if the issue is the code?
Thanks in advance.
Regards
Chris
p.s would be grateful if you could obscure the path above before posting.
Hi Chris,
Ah - that would be because the Price Tapestry standard includes haven't been require()'d - have a go with:
<?php
require("includes/common.php");
$productName = "Product Name";
$sql = "SELECT price,merchant FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($productName)."' ORDER BY price LIMIT 1";
database_querySelect($sql,$rows);
print "<p>Best price is ".$config_currencyHTML.$rows[0]["price"]." from ".$rows[0]["merchant"]."</p>";
?>
That should be all it is!
Cheers,
David.
--
PriceTapestry.com
Thanks David, it's working perfectly now.
Regards
Chris
Hi David,
I have just noticed that when the lowest (or only) price is Amazon nothing is displayed. Would be grateful if you could suggest if there is a way to include the Amazon result when they offer the lowest price.
Thanks in advance.
Regards
Chris
Hi Chris,
Presumably the means that the product is no longer in the database, in which case, do you have a modification to products.php that will show Amazon alone even if no database result?
If that's the case, perhaps if you could email me your current version of that file, and then it should be possible to replicate with a call to the Amazon API in the above code...
Cheers,
David.
--
PriceTapestry.com
Hello Chris,
Sure - the PHP to do that would as follows - simply adjust the value of $productName to match the product being reviewed and this should do the trick...
<?php
$productName = "Product Name";
$sql = "SELECT price,merchant FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($productName)."' ORDER BY price LIMIT 1";
database_querySelect($sql,$rows);
print "<p>Best price is ".$config_currencyHTML.$rows[0]["price"]." from ".$rows[0]["merchant"]."</p>";
?>
Cheers,
David.
--
PriceTapestry.com