X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   The universal solution "Continue Shopping Button" (https://forum.x-cart.com/showthread.php?t=39603)

glsp 09-25-2008 07:54 PM

Re: The universal solution "Continue Shopping Button"
 
My client requested that the visitor be returned to the last category they were viewing, rather than the last product or any other page. I decided to stick this near the bottom of my auth.php file so the last category info would follow the visitor around the site (removing the other code from cart.php):
PHP Code:

#
# Custom code: Continue Shopping link
#
x_session_register("last_cat");
$referrer $_SERVER['HTTP_REFERER'];
if (
strpos($referrer"home.php")) {
    
$last_cat $referrer;
}
else if (!
$last_cat) {
    
$last_cat 'home.php';
}
$smarty->assign("back_url"$last_cat);
# End Continue Shopping 


Yurij 09-26-2008 12:36 AM

Re: The universal solution "Continue Shopping Button"
 
Quote:

Originally Posted by glsp
My client requested that the visitor be returned to the last category they were viewing, rather than the last product or any other page. I decided to stick this near the bottom of my auth.php file so the last category info would follow the visitor around the site (removing the other code from cart.php):
PHP Code:

#
# Custom code: Continue Shopping link
#
x_session_register("last_cat");
$referrer $_SERVER['HTTP_REFERER'];
if (
strpos($referrer"home.php")) {
    
$last_cat $referrer;
}
else if (!
$last_cat) {
    
$last_cat 'home.php';
}
$smarty->assign("back_url"$last_cat);
# End Continue Shopping 



What should happen if the transition to the cart was made from the page - Manufacture, search or etc.?

glsp 09-26-2008 03:50 PM

Re: The universal solution "Continue Shopping Button"
 
In this case, transfers from those pages would not be counted. We don't use Manufacturers, but you could add conditions to check for any page to go back to. In the case of search, the code could be:
PHP Code:

x_session_register("last_cat");
$referrer $_SERVER['HTTP_REFERER'];
if (
strpos($referrer"home.php") || strpos($referrer"search.php")) {
    
$last_cat $referrer;
}
else if (!
$last_cat) {
    
$last_cat 'home.php';
}
$smarty->assign("back_url"$last_cat); 


ewebartist 10-01-2008 06:18 PM

Re: The universal solution "Continue Shopping Button"
 
Yurij,

The code works perfectly in X-cart 4.1.11. Excellent work, thank you for sharing it with the X-cart community!

Best regards,
e-webartist

TanyaG 10-15-2008 03:23 AM

Re: The universal solution "Continue Shopping Button"
 
Great job. Thank you so much for sharing. Is it any chance to send customers back into root directory instead of subcategory?

Many thanks

Yurij 10-15-2008 05:57 AM

Re: The universal solution "Continue Shopping Button"
 
Quote:

Originally Posted by TanyaG
Great job. Thank you so much for sharing. Is it any chance to send customers back into root directory instead of subcategory?

Many thanks


Try change in "cart.php" code for universal solution "Continue Shopping Button" by this:

PHP Code:

#back URL when cont. shoping:

x_session_register("back_url");
if (
$mode == "add")
{
    
$back_url $_SERVER['HTTP_REFERER'];

    
$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); 


Michael Burns 10-16-2008 09:23 AM

Re: The universal solution "Continue Shopping Button"
 
X-cart total newbie here. PHP, and SQL challenged.. Could someone please post or pm me the files and the edits including making the button, and all things needed to make this work in 4.1.10. I would love the ability to send the user back to the catagory they were viewing just before they hit add to cart. Right now the only thing I can tell thim is hit their backspace key to go back to that position.

Thanks Mike

junaid 10-17-2008 02:16 AM

Re: The universal solution "Continue Shopping Button"
 
Quote:

Originally Posted by Yurij
Try change in "cart.php" code for universal solution "Continue Shopping Button" by this:

PHP Code:

#back URL when cont. shoping:

x_session_register("back_url");
if (
$mode == "add")
{
    
$back_url $_SERVER['HTTP_REFERER'];

    
$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); 



please let me know can it made with just last category we were on as it seems cart taking more time to load with sql above may be im wrong.

Yurij 10-17-2008 04:30 AM

Re: The universal solution "Continue Shopping Button"
 
Quote:

Originally Posted by junaid
please let me know can it made with just last category we were on as it seems cart taking more time to load with sql above may be im wrong.


Try change in "cart.php" code for universal solution "Continue Shopping Button" by this:

PHP Code:

#back URL when cont. shoping:

x_session_register("back_url");
if (
$mode == "add")
{
    
$back_url $_SERVER['HTTP_REFERER'];

    
$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])) {
                
$last end($cats_path);
                
$back_url "home.php?cat=".$last;
            }
        }
    }
}
$smarty->assign("back_url"$back_url); 


This modification just add one sql query (On load the page X-cart makes 80-140 query to DB :) ).

Michael Burns 10-17-2008 06:12 AM

Re: The universal solution "Continue Shopping Button"
 
Thanks so much Yurij. Works like a charm!


All times are GMT -8. The time now is 02:59 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.