Might I suggest "Keep Cart" (https://www.zen-cart.com/downloads.php?do=file&id=992) instead? That's a lot less cookie-weight and I've actually been keeping it updated!
Might I suggest "Keep Cart" (https://www.zen-cart.com/downloads.php?do=file&id=992) instead? That's a lot less cookie-weight and I've actually been keeping it updated!
Well, I'm actually using both... keep cart to save un logged in carts, and remember me to automatically log back in if you have an account.
Lol, of corse I am. I use a LOT of your plugins.
Please consider the following scenario for a customer who has activated auto-login. They go to the store and select a product and checkout, so the checkout_success page is displayed. They close the browser or move to another site. After the zc session expires, they come back to the checkout_success page through browser history or other means. They are auto-logged in and the checkout success page is displayed. Is auto-login configured to deal with this scenario correctly? What if the customer goes back to an earlier stage of checkout?
In my case, I have an observer triggered by NOTIFY_HEADER_END_CHECKOUT_SUCCESS that gets executed when the customer comes back and the page is displayed again. The observer fails because some data is missing. So I don't need or want the observer to execute when this scenario is encountered, since the observer did its thing when the customer first checked out successfully. Five different customers have triggered this error in the last two months so it's a problem I need to fix.
Unfortunately, I can't figure out a way to detect this scenario in the observer. Any ideas would be appreciated!
What worries me in addition, is what happens if the customer comes back to other pages in the store and whether the core and custom code will work.
If auto-login is not chosen by the customer, and the scenario is followed, the "Whoops, the session has expired" page is displayed, so I feel fairly certain nothing incorrect will occur for those customers.
Thank you for any advice/help you can provide.
Dave
zc157c, php 8
I'm looking for a general solution that would detect the scenario regardless of the page returned to, and not re-execute any damaging code. I've already tested for the missing data (a custom session variable) in the observer and bypassed primary observer logic, so there are no myDEBUG messages. There is an email sent to me when the missing session data is detected with debug data. So I'm not sure what good the observer code will do.
What I was thinking of was a test on the "came from page", or a test on the current date-time relative to the order date_purchased date-time. In the case of returning to the checkout_success page, the "came from page" must be the order_confirmation page, otherwise the scenario was encountered. The time test would see if the time difference was less than say 20 minutes or else the scenario was encountered. But those are just preliminary thoughts, and I'm not sure how to get the "came from page" or even if it's possible.
Info on the observer...the observer automatically sets the order status and sends the order status update email for certain types of orders based on a custom session variable $_SESSION['order_case'] that's set elsewhere. It also tailors some text in the order status update email based on what was ordered. The idea was to relieve the admins from setting status and sending emails when they could be sent automatically at order time. The observer is too large to include as attachment to this site.
Dave
Last edited by Dave224; 7 Nov 2023 at 06:50 PM.
Another possible idea would be to redirect to the home page or login page on auto-login, regardless of what page was requested by the browser. This could potentially avoid all negative impacts of coming back to the site on a "bad" page. This would need to be a change (I believe) to the auto-login add-on.
Dave
Last edited by Dave224; 7 Nov 2023 at 07:01 PM.
Since manual login success loads the home page, I've decided to load the home page on auto-login too, even if the customer entered the store with a bookmark, browser history item, or restored a previous (browser) session. I inserted the following line after the update to the customers_info table in function checkRememberCustomer in file includes/classes/observers/class.remember_me_observer.php.
I have tested the code with and without products in the cart and all appears to work properly.Code:if (isset($_GET['main_page']) && $_GET['main_page'] !== 'index') $_GET['main_page'] = 'index'; // edit to force home page to load on auto-login
Dave
note for php 8.3:
to fix a ton of "--> PHP Deprecated: Creation of dynamic property remember_me_observer::$XXXXXX"
errors I added the following to /includes/classes/observers/class.remember_me_observer.php at about line 23:
I won't swear it's right, but it does seem to work (in zen 2.0.1 even) and made the errors stop.Code:public $enabled, $checkbox_default, $debug, $logfilename, $customer_remembered, $customerIsLoggedIn, $path, $domain;
Bookmarks