View Single Post
  #66  
Old 11-30-2008, 05:02 AM
 
xsurf xsurf is offline
 

Advanced Member
  
Join Date: Mar 2008
Posts: 56
 

Default Re: The universal solution "Continue Shopping Button"

Just when you would have thought all permutations have been considered, time for a new challenge .

What I am trying to do is the following: if arrived to the cart by adding an item, then "continue shopping" should return me to the product category.

BUT if someon arrives to the cart in any other way (e.g. clicking on "view cart" from anywhere), then "continue shopping" should return them to the page they were on when they clicked on "view cart".

I tried
PHP Code:
x_session_register("back_url");
if (
strpos($_SERVER['HTTP_REFERER'], "cart.php") == false)
{
    
$back_url $_SERVER['HTTP_REFERER'];
}
if (
$mode == "add")

    
$id intval($productid);
       if (
$id>0
    {
           
$cat_path func_query_first_cell("select categoryid_path from $sql_tbl[products_categories]$sql_tbl[categories] where (productid = $id)and(main='Y')and($sql_tbl[products_categories].categoryid=$sql_tbl[categories].categoryid)");
        if (!empty(
$cat_path)) {
               
$cats_path split("/ *",$cat_path);        
                  if (!empty(
$cats_path[0])) {
                      
$back_url "home.php?cat=".$cats_path[0]; 
            }
        }        
    }
}

$smarty->assign("back_url"$back_url); 

but off course that just always gets me back to the page I was on before, never to the product category page, since every time cart.php?mode=add is called, it is immediately followed by a regular call to cart.php (with the referrer remaining the product detail page)...


Help?
__________________
X-cart Gold 4.1.12
One Page Checkout
CDSEO Pro
Smart Search
PHP 5.2.5
FreeBSD
Reply With Quote