![]() |
Login Form Modification
I hate the fact that x-cart takes you back to the home page if you log into the site without anything in your cart. Here's the mod that will take you back to the page you just came from when you log in.
+++++++++++++++++++++++++++++++++++++++++++++ This modification will take you back to the page you came from unless you have something in your cart. In the latter case, it will take you to your shopping cart. +++++++++++++++++++++++++++++++++++++++++++++ Original File: login.php Code:
if ($login_type=="C") { Code:
if ($login_type=="C") { +++++++++++++++++++++++++++++++++++++++++++++ This modification will allow you to control which pages redirect you back to shopping cart, which redirect you back to the homepage and which you want redirected back to the page they came from. Simply adjust the order to suit your priorities and add &locator=1 to any page's url that you would like the user to be redirected to once they log in. You can also add as many &locator=#'s to the if statement and move people all around the site :) +++++++++++++++++++++++++++++++++++++++++++++ Original File: login.php Code:
if ($login_type=="C") { Code:
if ($login_type=="C") { +++++++++++++++++++++++++++++++++++++++++++++ And finally... This modification is the same as the first one, but will also recognize if your user is logging in while in the middle of the checkout process of the shopping cart and will redirect them to the next step in the checkout process rather than taking them back to step one. +++++++++++++++++++++++++++++++++++++++++++++ Original File: login.php Code:
if ($login_type=="C") { Code:
if ($login_type=="C") { I have been adding to this message as I have been coding so it's kind or a patchwork of stuff, hope no one gets confused :!: |
You rule. I'll be adding these mods to my site soon.
|
Finally a response!!!
I'm glad someone likes these; I thought they were going to be a hit. They ended up being another Apple Newton. :lol: |
Man, I'm just impressed that you managed to untangle the login code enough to write this script. I've managed to tweak myself into a corner with respect to this. I had my DigitalSubscription module working perfectly in the old 3.1.3a version of x-cart and then upgraded and tried to re-modify the new version (3.3.1) and now all my customers have to create a login/password or the user's info is lost when they try to check out, until they fill in a username/password. I've got logic to check the cart contents and if they have any DigitalSubscripton products then we can't allow anonymous checkout. My code is now preventing ALL anonymous checkouts instead of just the one's containing DigitalSubscriptions (which they'll need a username and password to access). Not sure why yet, but I'd be interested to know how you approached your project above. Maybe I'm missing something that would make x-cart easier to understand? I understand all the languages (PHP,Smarty,JavaScript, etc) but when they're all working together on the same page, it gets very hard to follow.
|
Yeh, this is a great little mod.
This should be added to xcart as standard i think. Why not send this one to xcart |
Improved version
I took your code and made a few minor improvements. Using HTTP_REFERER is not foolproof, since it is set by the browser. So my code goes back to the original behavior if the REFERER is not set. Also, this code is for version 3.3.4 and handles checkout logins from both the "Click to login" link and from the regular login box (normally on the right-hand side).
Code:
$mysite_pattern = '~^(http://'.$xcart_http_host.'|https://'.$xcart_https_host.')~'; |
v3.3.5
How do I prevent anonymous checkout?
|
Nice one! I was just about to start hacking x-cart to bits to do exactly this! :) Ta dude.
|
Any idea how to make this work on 3.4.x?
Thanks. |
I tried it on 3.4.2 and the problem was that you filled out the form, and hit login, but it didn't log you in for some reason.
Now I'm not a programmer, but I did really well on pattern detection in an IQ test, so I think I have a fix :) It seems to work fine, the problem was with the following call to header function: Code:
header("Location: ../$redirect/cart.php"); In my version, the original login.php used the format: Code:
func_header_location("../$redirect/cart.php"); There are two instances in the mod snippet that require changing, but that's all and it seems to work like a charm :) So in the 3.4.2 version, the mod will be as follows: Original File: login.php (line 125) Code:
if ($login_type=="C") { Modified File: login.php Code:
if ($login_type=="C") { HTH, lemme know if it works for you. P.S. This works even if the customer is registering during checkout, and redirects them back to the page they were on, so they don't have to hit 'checkout' again :D I loved that! |
Seems like a pretty cool mod but regardless of which incarnation of it I use it only gets redirected to a blank page. The page source is cart.php?mode=auth but it is blank.
Im using Netscape 7.1 and Xcart 3.4.9 |
looks like you missed a } on the end of that coding ...
This is the revised coding ... Quote:
Tried it in 3.4.9 and works. |
Looks like I got this working with Hair Guy's code.
Here's what Im using for 3.4.10 Code:
# new login mod |
Great Mod, ought to be standard in X-Cart, but has anyone updated this for v3.5.x ?
PhilJ |
Quote:
There is a slight problem with this. Example: The customer tries logging in either through the side panel login box or the center login box but enters a wrong password or wrong username. The incorrect password/username message will show up, and then they enter the correct details and log in. The problem is that the incorrect password/username message will still show, and it might confuse some customers who will wonder why that message is still there if they just logged in correctly. How would you apply an exception to the code so that if the customer is logging in after an unsuccesful attempt, that it would either redirect them back to page they were at before or back to the home page. |
I ran into the same issue, and I just added an exception for the page "error_message.php?login_incorrect", as follows (this is my entire code snippet:
Code:
if ($login_type=="C") { Hope this helps. |
Hi, question about your login form solution
Hi,
Thank you for your modification, I was able to integrate it succesfully: "I ran into the same issue, and I just added an exception for the page "error_message.php?login_incorrect", as follows (this is my entire code snippet: " Code:
if ($login_type=="C") { What I have been having trouble with is integrating the checkout bit that was also in the same post. Were you able to get the correct code so that the customer would be redirected to step 2 if they signed in the middle of the checkout process? By the way, this bit for the above code also redirects them to home if they mistype their login/pw 3 times and are given the recover password screen: if ($relo_page == "error_message.php?login_incorrect" OR "help.php?section=Password_Recovery") Thanks, James |
for 3.5.7
if customer directory different name codes must be : Code:
if ($login_type=="C") { |
Hi,
I have recently begun a fresh install of v3.5.8. I don't know if it's just me, but when I modify login.php to redirect to the referring page, the cart still redirects to either home.php or the cart. I have deleted all cached templates etc. but am still having no luck. Is anyone else experiencing a similar problem? P.S - I have had the code working successfully in v3.5.7 thanks |
what would be the correct code if you had moved the contents from /customer into the root of your site? I did this so the site could be accessed by shop.com/home.php instead of shop.com/customer/home.php
I'm currently using this code: Code:
if ($login_type=="C") { The redirect for the cart.php works but the redirect for the relopage does not. It redirects to my index.html rather than home.php. |
Anyone got a update to this code for 4.0.x(5) ????
|
4.0.5 already does this, at least on my installation it does. It looks like X-Cart took your idea, and implemented it into the new version.
|
Anyone get this to work with 3.5.12 or .13?
|
All times are GMT -8. The time now is 08:02 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.