You are here:  » wishlist/order form


wishlist/order form

Submitted by shopinn on Sun, 2009-09-20 13:43 in

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

Submitted by support on Sun, 2009-09-20 14:00

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.

Submitted by empiricalWeb on Mon, 2009-10-05 07:33

I would be willing to pay additional funds for a "recently viewed" modification!

Submitted by ph on Mon, 2009-10-05 09:56

yeah, I totally need this too!

Submitted by Keeop on Mon, 2009-10-05 12:35

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

Submitted by support on Mon, 2009-10-05 12:38

Thanks for that contribution, Keeop...

Cheers,
David.

Submitted by smartprice24 on Wed, 2018-01-10 10:19

Hi David. Is possible limit products number view?

Thanks

Giuseppe

Submitted by support on Wed, 2018-01-10 10:59

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

Submitted by smartprice24 on Wed, 2018-01-10 11:58

Thanks David! Work fine!

Giuseppe

Submitted by kenan on Wed, 2018-03-14 19:37

Hi David,
How can I use this feature on 16/10A?
Thanks.

Submitted by support on Thu, 2018-03-15 08:41

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

Submitted by kenan on Thu, 2018-03-15 19:39

Thanks David,
It works great!