Hi,
I'm testing PricesExternal. Downloaded the latest version from post http://www.pricetapestry.com/node/2289#comment-12980
and with PT 12/10A.
Got SearchExternal working but when I test PricesExternal it doesn't show anything at first. So I noticed you have to be very specific. When I copied an exact product title it showed.
1. Can it be modified to be less specific?
2. I also noticed that the link for the merchant (under Stockist) gives a 404. Probably because of the modification where I moved PT one folder up (http://www.pricetapestry.com/node/3773). What should I change?
Hi,
What I tried was searching for "10 voor taal NDS" which is an exact product title, but I want "10 voor taal" to display the same products. I replaced the code, but this doesn't find the products.
PS: The stockist links works now.
Hi Marco,
Bear in mind that pricesExternal.php must only match a single product (it then returns the price comparison table for that product) - but you can make the search less specific if you're sure that there will be no overlap - in place of the modification described above to line 62, have a go with this instead:
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE name LIKE '".database_safe($q)."%' ORDER BY price";
The % character acts as a wildcard in the LIKE clause, so the above would match anything where the name begins with the name specified, e.g. "10 voor taal"...
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Great. And how can I modify it so that is has a min max price setting?
Hi Marco,
In your calling code you could preset $_GET["minPrice"] and $_GET["maxPrice"] and then use them in the SQL in the same way that they are used in search results - but make sure this is what you want to do as you may be removing results for a particular product by doing this... Have a go with:
if (isset($_GET["minPrice"]))
{
$minPrice = sprintf("%.2f",$_GET["minPrice"]);
}
else
{
$minPrice = "";
}
if (isset($_GET["maxPrice"]))
{
$maxPrice = sprintf("%.2f",$_GET["maxPrice"]);
}
else
{
$maxPrice = "";
}
if ($minPrice || $maxPrice)
{
if ($minPrice && $maxPrice)
{
$priceWhere = " AND price BETWEEN '".$minPrice."' AND '".$maxPrice."' ";
}
elseif ($minPrice)
{
$priceWhere = " AND price > '".$minPrice."' ";
}
elseif ($maxPrice)
{
$priceWhere = " AND price < '".$maxPrice."' ";
}
}
else
{
$priceWhere = "";
}
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE name LIKE '".database_safe($q)."%' ".$priceWhere." ORDER BY price";
Cheers,
David.
--
PriceTapestry.com
Hi,
I tried to preset it by adding these two lines to it right after the line: $q = (isset($_GET["q"])?$_GET["q"]:"");
$minPrice = ($_GET["minPrice"]?sprintf("%.2f",$_GET["minPrice"]):"");
$maxPrice = ($_GET["maxPrice"]?sprintf("%.2f",$_GET["maxPrice"]):"");
But where should I add the remaining?
Hi Marco,
The code above was intended as a replacement for the single line of code $sql = ... in the post prior to that. In other words, in your current pricesExternal.php I think you should have this code around line 62:
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE name LIKE '".database_safe($q)."%' ORDER BY price";
...so REPLACE that with:
if (isset($_GET["minPrice"]))
{
$minPrice = sprintf("%.2f",$_GET["minPrice"]);
}
else
{
$minPrice = "";
}
if (isset($_GET["maxPrice"]))
{
$maxPrice = sprintf("%.2f",$_GET["maxPrice"]);
}
else
{
$maxPrice = "";
}
if ($minPrice || $maxPrice)
{
if ($minPrice && $maxPrice)
{
$priceWhere = " AND price BETWEEN '".$minPrice."' AND '".$maxPrice."' ";
}
elseif ($minPrice)
{
$priceWhere = " AND price > '".$minPrice."' ";
}
elseif ($maxPrice)
{
$priceWhere = " AND price < '".$maxPrice."' ";
}
}
else
{
$priceWhere = "";
}
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE name LIKE '".database_safe($q)."%' ".$priceWhere." ORDER BY price";
This incorporates reading $_GET["minPrice"] and $_GET["maxPrice"] so the code you added won't be needed i'm afraid - but the above should do the trick... If you're not sure of course email me your latest pricesExternal.php and I'll fix it up for you...
Cheers,
David.
--
PriceTapestry.com
Thanks. I'm looking at the translation now of the terms 'Prices', Stockist, Catalogue Product Name and Price, but it doesn't seem to get the translation from translate.php ?
I also noticed the formatting from the colomn headers is a bit strange? It is indenting a bit, see e.g.:
{link saved}
Hi Marco,
When calling the extenal scripts the CSS that is normally applied to the prices table, search results etc. doesn't apply, as the page is not a Price Tapestry generated page, your Price Tapestry default.css won't have been included. The prices table will therefore be being displayed however a table is intended to be styled based on your Wordpress theme.
However, the prices table is declared within a DIV of class "prices", so in your Wordpress theme, to remove the indentation on the column headings you should be able to add:
.prices th {
text-align: left;
}
For translation when using the external scripts, if the translate() library has not been included (because Wordpress already defines a translate() function) it's best to modify your html/prices.php directly and replace the English text with your translated equivalents directly...
Cheers,
David.
--
PriceTapestry.com
Thank you, I used:
th {
text-align: left;
}
And it looks very nice now.
Hi Marco,
pricesExternal.php by default requires the normalised name which is the version that normally constructs a URL, however since that isn't an issue when using pricesExternal.php it can be easily modified to use the regular name instead - so you can simply copy the name of the product you want from the Price Tapestry page for it, or from Product Finder in your /admin/ area. To do this, look for the following code at line 58:
$q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],":\."):"");
...and REPLACE with:
$q = (isset($_GET["q"])?$_GET["q"]:"");
And then at line 62:
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE normalised_name = '".database_safe($q)."' ORDER BY price";
...REPLACE with:
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE name = '".database_safe($q)."' ORDER BY price";
To fix the Stockist links for your site, look for the following code at line 62:
$rows[$k]["merchantHREF"] = $config_baseHREF."merchant/".tapestry_hyphenate($row["merchant"])."/";
...and REPLACE with:
$rows[$k]["merchantHREF"] =
"/merchant/".tapestry_hyphenate($row["merchant"])."/";
Cheers,
David.
--
PriceTapestry.com