View Single Post
  #17  
Old 01-06-2005, 11:48 AM
 
inthepink inthepink is offline
 

Newbie
  
Join Date: Aug 2004
Posts: 1
 

Default alternative method using sessions

I wanted to be able to have a continue shopping button on any page that would automatically bring the user back to the last category or product they viewed. Obviously using history steps wouldn't work in this case. If anyone is intersted, here is how I did it:

Add this code to the end of config.php
Code:
x_session_register("last_cat"); x_session_register("last_productid"); if($HTTP_GET_VARS['cat'] != "") { $last_cat = $cat; } if($HTTP_GET_VARS['productid'] != "") { $last_productid = $productid; } $smarty->assign("last_productid", $last_productid); $smarty->assign("last_cat", $last_cat);

Then create a template similar to this one and save it as "buttons/continue_shopping.tpl":
Code:
{if $goto eq "product" and $last_productid neq ""} {assign var="href" value="`$WebDir`/product.php?productid=`$last_productid`"} {elseif $last_cat neq ""} {assign var="href" value="`$WebDir`/home.php?cat=`$last_cat`"} {else} {assign var="href" value="`$http_location`"} {/if} [img]{$ImagesDir}/buttons/continue_shopping.gif[/img]

Include the template anywhere you want to point the customer back to the last category or product they viewed.

To send them back to the last product include the template like this:
Code:
{include file="buttons/continue_shopping.tpl" goto="product"}

For the last department just include it like this:
Code:
{include file="buttons/continue_shopping.tpl"}

If the customer hasn't visited a department or product yet this sends them back to the homepage. Since this uses sessions, you can use it on any page no matter how many steps away from a department they've traveled.

Hope someone finds this useful.

Jay
__________________
X-Cart - Version 4.0.2
Reply With Quote