hi david is it possible to add a wishlist / order form so visitors can click a button as they browse and then print the list with the products they have selected
best regards
dave
I would be willing to pay additional funds for a "recently viewed" modification!
Hi chaps,
I knocked up some code to store a user's viewed products in a cookie. You should be able to do the same for a 'wishlist' but would need to change the code to add the product to the cookie at the user's request. You'd probably also want to change the length of the cookie to a lot longer. Put this code at the bottom of products.php, just above
require("html/header.php");
Code to add:
// ***** Set Cookie Stuff for Product Views ******
if (!isset($_COOKIE['viewed']))
{
// if a cookie does not exist
// set it
setcookie("viewed", $q, time()+(86400*7), "/") or die;
}
else
{
$cook = $_COOKIE['viewed'];
if (stripos($cook, $q) === false)
{
$cook = $cook.",".$q;
setcookie("viewed", "", time()-3600, "/");
setcookie("viewed", $cook, time()+(86400*7), "/") or die;
}
}
Then, wherever you want to view the list of viewed products, add this code:
$viewhist = explode(",", $_COOKIE['viewed']);
print "Recently Viewed: ";
$vc = 0;
$tmpvw = $viewhist[$vc];
while (strlen($viewhist[$vc]) > 1)
{
echo "<a href='".$config_site."/product/".tapestry_hyphenate($viewhist[$vc]).".html'>".$viewhist[$vc]."</a>, ";
$vc++;
}
You can adjust the output to suit. At the moment, it's in a single line format. Oh, and the cookie is stored for a week. Oh, $config_site = http://www.your-site.com - I must have tried using $config_baseHREF but found it not to work for some reason but it's worth a try on your site.
Hope that's useful, and there's no charge!
Cheers.
Keeop
Hi David. Is possible limit products number view?
Thanks
Giuseppe
Hello Giuseppe,
In the code above, where you have this line:
$cook = $cook.",".$q;
...if you REPLACE with:
$cook = $cook.",".$q;
$parts = explode(",",$cook);
if (count($parts) > 10)
{
array_shift($parts);
}
$cook = implode(",",$parts);
...that will limit the list to a maximum of 10 products, with the oldest (first in the list) dropped...
Cheers,
David.
--
PriceTapestry.com
Hi David,
How can I use this feature on 16/10A?
Thanks.
Hi,
The example above fundamentally works fine in 16/10A, here's a slight modification to the display component including an isset() check on the cookie, and then generating the output within a Foundation row / unordered list...
if (isset($_COOKIE['viewed']))
{
print "<div class='row'>";
print "<div class='small-12 columns'>";
$viewhist = explode(",", $_COOKIE['viewed']);
print "<h4>Recently Viewed:</h4>";
print "<ul>";
$vc = 0;
$tmpvw = $viewhist[$vc];
while (strlen($viewhist[$vc]) > 1)
{
echo "<li><a href='".tapestry_productHREF(array("normalised_name"=>$viewhist[$vc]))."'>".$viewhist[$vc]."</li>";
$vc++;
}
print "</ul>";
print "</div>";
print "</div>";
}
Cheers,
David.
--
PriceTapestry.com
Hi Dave,
This is something that i've thought about before - a sort of "bookmarks within this site" - similar to a "recently viewed" products perhaps implement via a cookie. I'll look into this for you as I think it could be quite a nice feature as when people discover your site again they could go straight to products that they viewed earlier without having to search again - and more importantly you don't have to rely on them to bookmark pages within your site themselves...
Cheers,
David.