Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

The universal solution "Continue Shopping Button"

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #51  
Old 09-25-2008, 07:54 PM
 
glsp glsp is offline
 

Member
  
Join Date: Dec 2007
Location: Northampton, MA
Posts: 27
 

Default 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 
__________________
X-Cart Gold version 4.1.9

PS: This is what part of the alphabet would look like if Q and R were eliminated.
Reply With Quote
  #52  
Old 09-26-2008, 12:36 AM
  Yurij's Avatar 
Yurij Yurij is offline
Banned
 

X-Adept
  
Join Date: Jan 2008
Posts: 486
 

Default 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.?
Reply With Quote
  #53  
Old 09-26-2008, 03:50 PM
 
glsp glsp is offline
 

Member
  
Join Date: Dec 2007
Location: Northampton, MA
Posts: 27
 

Default 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); 
__________________
X-Cart Gold version 4.1.9

PS: This is what part of the alphabet would look like if Q and R were eliminated.
Reply With Quote
  #54  
Old 10-01-2008, 06:18 PM
 
ewebartist ewebartist is offline
 

Advanced Member
  
Join Date: Aug 2007
Posts: 55
 

Default 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
__________________
Cool.

X-Cart v 4.1.8 (Live Site - Slowly dying)
X-Cart v 4.1.11 (In Development- Being born)

Joomla 1.5.6 + X-cart 4.1.11 Integration complete Killer combination!
Reply With Quote
  #55  
Old 10-15-2008, 03:23 AM
 
TanyaG TanyaG is offline
 

Advanced Member
  
Join Date: Nov 2007
Posts: 94
 

Default 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
__________________
Tanya

x-cart version: 4.1.7 4.1.9. 4.2
Reply With Quote
  #56  
Old 10-15-2008, 05:57 AM
  Yurij's Avatar 
Yurij Yurij is offline
Banned
 

X-Adept
  
Join Date: Jan 2008
Posts: 486
 

Default 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); 
Reply With Quote
  #57  
Old 10-16-2008, 09:23 AM
 
Michael Burns Michael Burns is offline
 

Advanced Member
  
Join Date: Oct 2008
Posts: 41
 

Default 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
__________________
Version 4.4.3 Gold mod illiterate and mostly confused
Reply With Quote
  #58  
Old 10-17-2008, 02:16 AM
 
junaid junaid is offline
 

Advanced Member
  
Join Date: Dec 2003
Posts: 96
 

Default 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.
__________________
xcart 4.18 on linux
Reply With Quote
  #59  
Old 10-17-2008, 04:30 AM
  Yurij's Avatar 
Yurij Yurij is offline
Banned
 

X-Adept
  
Join Date: Jan 2008
Posts: 486
 

Default 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 ).
Reply With Quote
  #60  
Old 10-17-2008, 06:12 AM
 
Michael Burns Michael Burns is offline
 

Advanced Member
  
Join Date: Oct 2008
Posts: 41
 

Default Re: The universal solution "Continue Shopping Button"

Thanks so much Yurij. Works like a charm!
__________________
Version 4.4.3 Gold mod illiterate and mostly confused
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 01:51 AM.

   

 
X-Cart forums © 2001-2020