OK, first, I know this script has a *great* product compare page. I'll make use of it on other projects, I promise :)
Anyway, on the project I'm doing (where no product is the same), there's no point in this page, and it's better to minimise the number of clicks the user needs to make before he/she finds the product.
So, I'd like to skip out the very nice product info page and just go straight to the Buy URL.
I tried making the image and text href to
"<?php print tapestry_buyURL($mainProduct); ?>"
...but that just links to the current page.
Anybody care to shed some light on this?
Thanks!
Worked like a dream.
Best script support in the world, although everything seems to have been already thought of!
Hello David
Further to the question above.
Would it be possible to have both options.
E.g add a purchase link/button?
thanks
Mally
Hi Mally,
Sure - in this case the mod would have to go in html/searchresults.php. Look for the following code on line 29:
<span class='nobr'><a href='<?php print $product["productHREF"]; ?>'><?php print translate("More Information"); ?></a></span>
...and change this as follows to add a "Visit Store" (or whatever you want to call it) link below the "More Information" link...
<span class='nobr'><a href='<?php print $product["productHREF"]; ?>'><?php print translate("More Information"); ?></a></span>
<span class='nobr'><a href='<?php print tapestry_buyURL($product); ?>'>Visit Store</a></span>
Cheers,
David.
Hey, any chance we can add the visit store to the browse merchants list? As the tapestry_buyURL($product) just points to /jump?id= with no ID number.
Cheers, Steven
Hi Steven,
As it stands, there is no direct to merchant link in the database - all links are "product" links, and therefore only in the result set when querying products. tapestry_buyURL() then creates a jump link pointing to the id of the product record.
There are various options for doing this. One involves maintaining a list of non-product related merchant affiliate links that can then be used on the merchant page; or alternatively; would selecting a product at random from that merchant, and then re-directing to that page on the merchant site be suitable?
Cheers,
David.
Thanks David, I think maintaining a list of non-product related merchant affiliate links that can then be used on the merchant page would be best. How would I do this?
Cheers, Steven
Hi Steven,
The easiest way to do this; without the need to create new database tables and associated management tools is to create a new version of html/atoz.php that is used specifically for the merchant index.
To do this, first make a copy of html/atoz.php and call it, for example, html/merchantatoz.html.
In the new file, right at the top, add the following PHP to create a list of direct to merchant affiliate links for some/all of your merchants:
<?php
$affiliateLinks["Merchant A"] = "http://www.someaffiliatenetwork.com/affiliate=1234&mid=5678";
$affiliateLinks["Merchant B"] = "http://www.merchantB.com/index.php?affid=1234";
?>
And then to make use of these links, look for the following existing code (line 43 of the distribution):
print "<p><a href='".$item["href"]."'>".$item["name"]."</a></p>";
...and replace this with:
if ($affiliateLinks[$item["name"]])
{
$visitStore = " <a href='".$affiliateLinks[$item["name"]]."'>Visit Store</a>";
}
else
{
$visitStore = "";
}
print "<p><a href='".$item["href"]."'>".$item["name"]."</a> ".$visitStore."</p>";
Finally, to make the merchant index use the new version of atoz.php, modify merchants.php, and replace the following code (line 39):
require("html/atoz.php");
...with:
require("html/merchantatoz.php");
Cheers,
David.
Hey David,
this code didn't work, I think I caught you out ;-)
if ($affiliateLinks[$item["name"]])
{
$visitStore = " <a href='".$affiliateLinks[$item["name"]]."'>Visit Store</a>";
}
else
{
$visitStore = "";
}
print "<p><a href='".$item["href"]."'>".$item["name"]."</a></p>";
So I replaced the last line of this code with
print "<strong>" .$visitStore."</strong><br />";
I called $visitStore, which your code was missing. Does this look ok to you. Seems to work fine.
Thanks, Steven
Just thought David,
is there a way of doing this so the urls will be masked and go through jump.php as usual? Cheers
Hi Steve,
Sorry - i've corrected the code above.
Regarding altering this so that it uses jump.php - sure that's possible - it would just require you to maintain two corresponding look-up tables in the two files. To do this, in place of the first array, use:
<?php
$affiliateLinks["Merchant A"] = 1;
$affiliateLinks["Merchant B"] = 2;
?>
...and then replace the following line:
$visitStore = " <a href='".$affiliateLinks[$item["name"]]."'>Visit Store</a>";
...with this:
$visitStore = " <a href='".$config_baseHREF."jump.php?mid=".$affiliateLinks[$item["name"]]."'>Visit Store</a>";
...so that we're passing an "mid" parameter to jump.php.
Finally, at the top of jump.php, add this code to check for the mid parameter and redirect if it is set:
<?php
$affiliateLinks[1] = "http://www.someaffiliatenetwork.com/affiliate=1234&mid=5678";
$affiliateLinks[2] = "http://www.merchantB.com/index.php?affid=1234";
if ($_GET["mid"])
{
header("Location: ".$affiliateLinks[$_GET{"mid"]]);
exit();
}
?>
(where 1,2 etc, correspond to Merchant A, Merchant B etc, in merchantatoz.php)
Cheers,
David.
Hey David the above code gives the following errors:
: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/stev7879/public_html/includes/database.php on line 21
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /includes/database.php on line 26
Warning: Cannot modify header information - headers already sent by (output started at /jump.php:10) in /jump.php on line 45
But after doing this i've realised theres alot of admin involved with the amount of merchants I have. Can you tell me how to place visit store links on the browse category page, which select a randon product url from the feed, and goes through jump.php.
Cheers!
Hi Steve,
Sure - firstly - the error in jump.php is caused by PHP beginning the output at the point between the 2 blocks of PHP. With this new version, remove the code added above, and look for the following code on line 2 of jump.php:
require("includes/common.php");
...and add the following code immediate after:
if ($_GET["merchant"])
{
$sql = "SELECT buy_url FROM `".$config_databaseTablePrefix."products` WHERE merchant='".database_safe($_GET["merchant"])."' ORDER BY RAND() LIMIT 1";
database_querySelect($sql,$rows);
header("Location: ".$rows[0]["buy_url"]);
exit();
}
This code will check for a "merchant" parameter (which we can pass through from anywhere) and then select a random product from that merchant and jump to that URL:
Now, to add a "Visit Store" link to the merchant index (the category index page doesn't select merchant information from the database as it uses a summary query); you will need to create a copy of html/atoz.php and call it, for example, atozmerchants.php. Then, in the new file, look for the following code on line 43:
print "<p><a href='".$item["href"]."'>".$item["name"]."</a></p>";
...and replace this with:
print "<p><a href='".$item["href"]."'>".$item["name"]."</a> <a href='".$config_baseHREF."jump.php?merchant=".urlencode($item["name"])."'>Visit Store</a></p>";
Finally, in merchants.php, look for the following code on line 39:
require("html/atoz.php");
...and replace this with:
require("html/atozmerchants.php");
Cheers,
David.
Thanks, that works great. An error appeared at first so I changed
header("Location:$rows[0]["buy_url"]);
to
header("Location:".$rows[0]["buy_url"]);
just adding the ". and it works great! Thanks very much :-)
Thanks for pointing that out - i've corrected the original code above.
Cheers,
David.
When I click through to the merchant link on my product pages many of the pages that these jump to are corrupted. How do I change or eliminate these merchant links?
Hi Mark,
If merchant pages are corrupt, the first thing to do is to check that your feed is up to date. If so, I always get in touch with the merchant / Affiliate Network as they're normally keen to make sure their links are working correctly...
I also drop a subtle hint to merchants when contacting them that they could make a sales opportunity out of broken links by displaying similar products themselves; but very few actually do this i'm afraid - a lot of wasted opportunity given the amount of traffic affiliates are driving to them.
Cheers,
David.
Hi David,
I want to send the user straight to the merchant from the searchresults but only in the searchresultsExternal.php and only if there is one merchant for that product , so if there are 3 different merchants for the same product it then takes you to the product page.
so i would want the normal searchresults.php to keep going to the product page.
Hi Jonny,
That's no problem - the change would actually have to go in searchExternal.php. Look for the following code on line 210:
if ($config_useRewrite)
...and REPLACE that with:
if ($searchresults["products"][$k]["numMerchants"])
{
$searchresults["products"][$k]["productHREF"] = tapestry_buyURL($product);
}
elseif ($config_useRewrite)
Cheers,
David.
that works :) well the only thing is when there is two or more retailers so it says compare prices when you click it doesnt take you to the product page but straight to one of the retailers???
Hi Jonny,
Sorry - this line:
if ($searchresults["products"][$k]["numMerchants"])
...should have been:
if ($searchresults["products"][$k]["numMerchants"] == 1)
Cheers,
David.
Hi David/all
Is this possible on the featured products on the main page? I tried the following:
<a target='_BLANK' href='<?php print tapestry_buyURL($product); ?>'><img src='shop.png' border='0'></a>
It appears to work, however it does not seem to pick the right merchant i.e. if there is more than one merchant with the product clicked, it seems to pick one of them at random, not necessarily the one with the lowest price?
Thanks in advance
Hi,
Unfortunately in this case the featured products are selected using a summary query, so the row from which fields other than the summary values (e.g. minPrice) are selected cannot be determined. What it would be necessary is do is to re-query each product after the main Featured Products query to select the id and buy_url from the lowest price product record for each product.
To do this, look for the beginning of the following loop in index.php (line 59 in the distribution):
foreach($featured["products"] as $k => $product)
{
...and REPLACE with:
foreach($featured["products"] as $k => $product)
{
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($product["name"])."' AND price='".$product["minPrice"]."' LIMIT 1";
database_querySelect($sql,$rows);
$featured["products"][$k]["id"] = $rows[0]["id"];
$featured["products"][$k]["buy_url"] = $rows[0]["buy_url"];
Your modification in html/featured.php is correct and still required of course with the above modification in place...
Hope this helps!
Cheers,
David.
I've just tried this modification and it work. {link saved} here the product images still just go to the product page?
Hi kimarie,
As you're using the external script on that page the direct to merchant modification would need to go into external.php rather than index.php on your Price Tapestry installation.
In your external.php, look for the following code at around line 510:
$searchresults["products"][$k]["productHREF"] = $internal_baseHREF."product=".urlencode($product["name"]);
...and REPLACE that with:
if ($product["numMerchants"]==1)
{
$searchresults["products"][$k]["productHREF"] = tapestry_buyURL($product);
}
else
{
$searchresults["products"][$k]["productHREF"] = $internal_baseHREF."product=".urlencode($product["name"]);
}
That will create direct to merchant links whenever there is only one merchant for a result, otherwise display the price comparison table...
Cheers,
David.
--
PriceTapestry.com
Hi Harvey,
To make the links on the search results page go straight to the merchant, you need to make the change in search.php. Look for the following code (starting at Line 141):
if ($config_useRewrite)
{
$searchresults["products"][$k]["productHREF"] = "product/".tapestry_hyphenate($product["name"]).".html";
if ($rewrite) $searchresults["products"][$k]["productHREF"] = "../../".$searchresults["products"][$k]["productHREF"];
}
else
{
$searchresults["products"][$k]["productHREF"] = "products.php?q=".urlencode($product["name"]);
}
You can change that simply to:
$searchresults["products"][$k]["productHREF"] = tapestry_buyURL($product);
(you don't need the IF statement anymore because whether or not you are using search engine friendly URLs is irrelevant if you are going off-site!)
That should do the trick...
Cheers,
David.