
12-02-2008, 07:02 AM
|
|
 | |
Banned
|
|
 X-Adept
|
|
Join Date: Jan 2008
Posts: 486
|
|
|
Re: The universal solution "Continue Shopping Button"
Quote:
Originally Posted by xsurf
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? 
|
I'm not sure, but try used next code (i don't tested this code enough):
PHP Code:
x_session_register("back_url"); x_session_register("skip_one_redirect");
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]; $skip_one_redirect = 1; } } } } else { if ($skip_one_redirect==1 ) { $skip_one_redirect=0; } else { if (strpos($_SERVER['HTTP_REFERER'], "cart.php") === false) { $back_url = $_SERVER['HTTP_REFERER']; } } }
$smarty->assign("back_url", $back_url);
|
|