Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

return to the page you were on prior to loggin in


dreamscape

Recommended Posts

I have placed a "log in" link on my navigation bar, as I have noticed many people have... and have found it quite annoying that I may be on a page (either browsing categories on default.php, looking at a product info, doing a search, looking at my cart, etc, etc...) and decide to login, and being redirected back to the main page after loggin in. I am sure customers who choose to login in the middle of browsing find it equally annoying...

 

so I did this... I added this code to the top of each page, not already setting the snapshot (like checkout and my account), so that upon login from any page, the user is redirected back to that page... again really only useful if you have a "login" link in the navbar or similar as I do:

 

I placed this directly after the call for application_top.php:

// if the customer is not logged on, set the page to return to upon login

 if (!tep_session_is_registered('customer_id')) {

   $navigation->set_snapshot();

 }

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Link to comment
Share on other sites

  • Replies 83
  • Created
  • Last Reply

perhaps a better place to put this is in application_top.php... but I am unsure about which pages should NOT have the snapshot set on them for navigation... login.php should not I know... but dunno if others should not. Here is a quick code I came up with for app_top, instead of placing the above on each page:

 

// if the customer is not logged on, set the page to return to upon login

 if ((basename($PHP_SELF) != FILENAME_LOGIN) && (!tep_session_is_registered('customer_id'))) {

   $navigation->set_snapshot();

 }

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Link to comment
Share on other sites

Need to also not reset the value if 'create' is in the filename for new accounts.

 

ok... here is the new code to exclude all "create..." files for new accounts:

 

// if the customer is not logged on, set the page to return to upon login

 if ((basename($PHP_SELF) != FILENAME_LOGIN) && (substr(basename($PHP_SELF), 0, 6) != 'create') && (!tep_session_is_registered('customer_id'))) {

   $navigation->set_snapshot();

 }

 

please let me know if there are other files which should be excluded from this... thanks

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Link to comment
Share on other sites

Need to also not reset the value if 'create' is in the filename for new accounts.

 

Can you expand on that for us, how would you do that?

Link to comment
Share on other sites

found a few other pages you would not want this on...

 

the popups... if u put this code in, open a popup (like image popup or search help or info shopping cart), and then goto login, you are redirected to the popup page... here is yet again the new code to exclude these pages as well:

 

// if the customer is not logged on, set the page to return to upon login

 if ((basename($PHP_SELF) != FILENAME_LOGIN) && (substr(basename($PHP_SELF), 0, 6) != 'create') && (substr(basename($PHP_SELF), 0, 5) != 'popup') && (substr(basename($PHP_SELF), 0, 4) != 'info') && (!tep_session_is_registered('customer_id'))) {

   $navigation->set_snapshot();

 }

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Link to comment
Share on other sites

Joshua!!!!

 

That is WAYYYY TOOO COOOLLLLL!!!!!

 

 

Now.....Can you do that so they can sign-off and return to the same page?????

Link to comment
Share on other sites

I placed this at the bottom of application_top.php

// WebMakers.com Added: Login and Logoff redirect

// if not logged in set return page for login

 if ( ((basename($PHP_SELF) != FILENAME_LOGIN and !strstr($PHP_SELF,'create')) && (!tep_session_is_registered('customer_id'))) ) {

   $navigation->set_snapshot();

 } else {

// if logged in set return page for logoff

   if ( basename($PHP_SELF) != FILENAME_LOGOFF and tep_session_is_registered('customer_id') ) {

     $navigation->set_snapshot();

   }

 }

 

I added this to logoff.php under the line: $cart->reset();

  

 if (sizeof($navigation->snapshot) > 0) {

   $origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);

   $navigation->clear_snapshot();

   tep_redirect($origin_href);

 }

 

I replaced the navigation bar table in header.php so there is a Login or Logoff link:

<table border="0" width="100%" cellspacing="0" cellpadding="1">

 <tr class="headerNavigation">

   <td class="headerNavigation">  <?php echo $breadcrumb->trail(' » '); ?></td>

   <td align="right" class="headerNavigation">

     <?php echo ( (tep_get_validate_show_link(FILENAME_LOGIN) ) ? ('<a href="' . tep_href_link(FILENAME_LOGIN, '', 'SSL') . '"' . ' " class="headerNavigation">' . HEADER_TITLE_LOGIN . '</a>  ') : ''); ?>

     <?php if (tep_session_is_registered('customer_id')) { ?>  | <a href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_LOGOFF; ?></a>   <?php } ?>

     <?php if ( tep_get_validate_show_link(FILENAME_ACCOUNT) ) { ?>|  <a href="<?php echo tep_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a>   <?php } ?>

     <?php if ( tep_get_validate_show_link(FILENAME_SHOPPING_CART) ) { ?>|  <a href="<?php echo tep_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_CART_CONTENTS; ?></a>   <?php } ?>

     <?php if ( tep_get_validate_show_link(FILENAME_CHECKOUT_PAYMENT) ) { ?>|  <a href="<?php echo tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_CHECKOUT; ?></a>    <?php } ?>

   </td>

 </tr>

</table>

 

I added a function to the header.php but this can be added to your favorite function file. Note: This has other things you could clean out as you probably are not using them.

// WebMakers.com Added: Validate navigation bar links

////

// Verify valid links to show for Down for Maintenance and Forced Login

 function tep_get_validate_show_link($what_link) {

   switch (true) {

     case ($what_link==FILENAME_LOGIN):

       if (DOWN_FOR_MAINTENANCE_NO_STORE=='1' or (DOWN_FOR_MAINTENANCE=='1' and DOWN_FOR_MAINTENANCE_LOGIN_OFF=='1')) {

         return false;

       }

       if (tep_session_is_registered('customer_id') and (!strstr($PHP_SELF,FILENAME_LOGIN) and !strstr($PHP_SELF,'create')) ) {

         return false;

       }

       return true;

     break;



     case ($what_link==FILENAME_ACCOUNT):

       if (DOWN_FOR_MAINTENANCE_NO_STORE=='1' or (DOWN_FOR_MAINTENANCE=='1' and DOWN_FOR_MAINTENANCE_LOGIN_OFF=='1')) {

         return false;

       }

       return true;

     break;



     case ($what_link==FILENAME_SHOPPING_CART):

       if (DOWN_FOR_MAINTENANCE_NO_STORE=='1' or DOWN_FOR_MAINTENANCE=='1') {

         return false;

       }

       if (NO_LOGIN_NO_PURCHASES=='1' and !tep_session_is_registered('customer_id')) {

         return false;

       }

       return true;

     break;



     case ($what_link==FILENAME_CHECKOUT_PAYMENT):

       if (DOWN_FOR_MAINTENANCE_NO_STORE=='1' or DOWN_FOR_MAINTENANCE=='1') {

         return false;

       }

       if (NO_LOGIN_NO_PURCHASES=='1' and !tep_session_is_registered('customer_id')) {

         return false;

       }

       return true;

     break;



     default:

       echo 'I do not know ' . $what_link;

       return true;

     break;

   }

 }

 

Now, from what I have tested, when I login, create account or logoff I go back to the page I was on.

 

NOTE: You no longer see the logoff.php page due to the redirect. I haven't worked out the bugs yet on that ... :D

 

Test over at:

http://www.8thoctave.com/osc_attributes

 

I think this works everywhere without making a mess.

Link to comment
Share on other sites

I placed this at the bottom of application_top.php

// WebMakers.com Added: Login and Logoff redirect

// if not logged in set return page for login

 if ( ((basename($PHP_SELF) != FILENAME_LOGIN and !strstr($PHP_SELF,'create')) && (!tep_session_is_registered('customer_id'))) ) {

   $navigation->set_snapshot();

 } else {

// if logged in set return page for logoff

   if ( basename($PHP_SELF) != FILENAME_LOGOFF and tep_session_is_registered('customer_id') ) {

     $navigation->set_snapshot();

   }

 }

 

Linda,

 

why the if else statement in app top?? both do the same the thing (set the snapshot) and one is going to be true all the time (customer is either logged in or they are logged out).

 

this is my code for app_top to catch the logout page, as well as any popup_*.php, and info_*.php pages (the popups).

 

// if the customer is not logged on, set the page to return to upon login

 if ( (basename($PHP_SELF) != FILENAME_LOGIN) && (basename($PHP_SELF) != FILENAME_LOGOFF) && (!strstr($PHP_SELF,'create')) && (!strstr($PHP_SELF,'popup')) && (substr(basename($PHP_SELF), 0, 4) != 'info') ) {

   $navigation->set_snapshot();

 }

 

I didn't want to redirect upon logoff either cause I like the nice little message telling the user they are safely logged off. so the code I placed in logoff.php is this:

        if (sizeof($navigation->snapshot) > 0) {

         $origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);

         $navigation->clear_snapshot();

         $link = $origin_href;

       } else {

         $link = tep_href_link(FILENAME_DEFAULT);

       }

 

then then on the continue button replaced

tep_href_link(FILENAME_DEFAULT)
with
$link

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Link to comment
Share on other sites

Thank you, Thank you. This has also just solved a completely different problem that has been plaguing me for days...

 

Using add multiple quantities (you remember this one Linda? also in Attributes Sorter etc) - the Continue Shopping button hasn't worked (only realized that a few days ago). It sets the navigation variable to the new file - addtocart.php. Now maybe I'm being dense, but sizeof($navigation->path)-2; sent it to addtocart.php, and I couldn't get it to accept a parameter other than -1 or -2. Maybe something could be changed in navigation_history.php to allow 3 levels of history. Anyway, to make a long story short, I changed shopping_cart.php (the line is somewhere around line 122) : to reference the $origin_href set in default.php, and presto, the Continue Shopping button now works.

Unexpect the Expected

Link to comment
Share on other sites

Thank you, Thank you. This has also just solved a completely different problem that has been plaguing me for days...

 

Using add multiple quantities (you remember this one Linda? also in Attributes Sorter etc)

 

Jeff? Did you ever get the multiple qty to work with products with attributes so the attributes could show on the listing and be selected from there on multiple products?

 

So far, I am still using the Qty box on ones without attributes and the buy now or some such button on ones with attributes.

Link to comment
Share on other sites

Jeff? Did you ever get the multiple qty to work with products with attributes so the attributes could show on the listing and be selected from there on multiple products?

 

Not yet, but I've been thinking about it without actually doing any coding. The site I needed it for won't ever be using attributes. - I've been going crazy the past couple of weeks trying to get a huge (non oscommerce) project live that I've been working on for the past year. Multiple servers, php, mysql, OpenBSD, Windows (uggh, but needed for axtivex components), linux, crossing domains (authenticating using sessions has been a delight - fought with losing session information for a few days until I realized the Windows server (in another city) was exactly 12 hours behind the other servers - as soon as authentication happened on it, the php session expired. Now one of the BSD boxes is a time server. This also could be a reason some folks are having trouble with oscommerce and seperate SSL servers storing session information in the database - if the time on the SSL server is skewed by more than the length of the session timeout - **poof**).

 

It's a full customer self-serve information system for an agricultural co-op. Started off as a little flat file database project to serve up customer statements, kinda grew.... Anyway, it's been promised to the co-op members that it will be live at the end of the month, and still have a bunch of tweaking to do. Then off to offer it up to other co-ops...

 

Of course in the middle of this I also have 6 new oscommerce sites (one of them for me!) that clients are clamoring for completion. The end of it is, I'm going to rexamine the attributes issue in a couple of weeks when all of the dust settles and I can concentrate on working with attributes. I've also got a few other ideas percolating in my tired little brain.

Unexpect the Expected

Link to comment
Share on other sites

I know what you mean about trying to get to features and code changes on the To Do List ...

 

I am so behind on that list it is not even funny!

 

All those dang clients clamouring for attention and wanting the work done now ... work that has nothing to do with osC what-so-ever ... it's blasphemy I swear ... 8)

Link to comment
Share on other sites

Joshua,

 

Thank you so much!! I absolutely love it! I have used the mod and now you can login using the login box and not lose your place! Perfect! I have also made a slight change and left out the logoff page (which I didn't have to start with ...older snapshot) This along with the combo login/create account page should smooth out the sign-in/up process and make the customers very happy.

Link to comment
Share on other sites

Kim? Which login box are you using?

 

I have written so many I cannot remember which ones work these days and which ones don't.

 

Can you please post your's as a contribution? I have too many versions to sort out.

Link to comment
Share on other sites

Linda,

 

That's the super cool part....I didn't have to modify the login box at all! I just added Joshua's code to the application_top and the other snippet to the logoff file.....Works like a charm!

 

Now all I have to do is figure out how to get the username/password error into the login box and life will be perfect. I'm thinkin' that the trigger should be changed into a function and added to functions/general php with the customer greetings....what do you think?

Link to comment
Share on other sites

Also your combo login/create account page ... mine stinks ... icon_rolleyes.gif

 

Oh yuck! The one I'm using on the shop is for a very old snap shot.....I have one for the MS1 almost put together and I'll be contributing it soon.

Link to comment
Share on other sites

My login boxes are flakey ... sometimes when on they result in going to the wrong page for some reason on various selections. :shock:

 

I have given up trying to debug them. Hence the desire to have your's ... :D

 

As to the message in the box, you could set a variable $broken_password or something ... then on the login error have it go back to the page it was on and show the $broken_password text.

 

I'd have to play with it.

 

Much easier to play with if I had a good login box and a good combo login/create account page ... <insert major hints here> 8)

Link to comment
Share on other sites

As to the message in the box, you could set a variable $broken_password or something ... then on the login error have it go back to the page it was on and show the $broken_password text.

 

Why worry about putting the error on the page you go back to... Why not put it in the login box instead of the customer greeting???? Better, easier, yes?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...