Jump to content

Make the "Already Registered?" button actually link to login page then re-direct back to checkout

Recommended Posts

Anyone else finds the "Already Registered?" button behavior on the checkout page flawed?

Clicking it triggers JS that simply shows the login username/password boxes without actually letting the user login. 

So the login is performed at the same time as order submission. The idea is that less clicking and not leaving the checkout page is a good thing. Except that:

1. Without actually logging in, the user has to enter the credit card manually instead of using the one on file. This defeats one of the most important benefits of being "registered".

2. If the user enters a credit that is different from the one he has on file, his card on file gets updated without even his knowledge, as no where on the order page suggests that.

3. If the user made a typo on the password, he does not seem to even get a  password incorrect error message, possibly causing confusion

Shouldn't the better approach be what every other online store does: clicking "Already Registered" button actually leads user to login page, then redirects back to the checkout page upon successful login?

Anyone has any idea how to achieve this (the button it self can be edited ini the template I assume, but what about the redirect part?)


Edited by startover909
Link to comment
Share on other sites

  • 2 weeks later...

I achieved this myself by creating a basic custom WHMCS page, loginredirectcheckout.php, that has "require login" enabled.


use WHMCS\ClientArea;
require __DIR__ . '/init.php';
$ca = new ClientArea();

Then on the corresponding  loginredirectcheckout.tpl  file, I simply added one line of  javascript code to  redirect to the checkout page.

    window.location = 'https://yourwhmcs/cart.php?a=checkout';

Then I edited the checkout.tpl template, replaced the existing "already registered"  and "register" buttons with a  link to the loginredirect.php file (apply btn and btn-info classes to the anchor to make it look just like the original button):

<a href="/yourwhmcs/loginredirectcheckout.php" class="btn btn-info{if $loggedin} hidden{/if}">{$LANG.orderForm.alreadyRegistered}</a>

Upon clicking, the user will be required to login, then once logged in, redirected right back to the checkout page.

Now credit card info pre-filled. No more confusions etc.

Hopefully this will help others who want their order form to behave like this.


Edited by startover909
Link to comment
Share on other sites

While you're at checkout.tpl (of course, you should copy the original order form template to create your own template), I also recommend that you remove the

 {if $loggedin || $custtype eq "existing"} class="hidden"{/if}

logic from the sign up container

 <div id="containerNewUserSignup"{if $loggedin || $custtype eq "existing"} class="hidden"{/if}>

This way, the users will see their pre-filled info with fields that are set to read-only (already by template) so they get to review their info before submitting the order. This gives them a chance to update their old info which can result in CC declines etc. You may also want to add a little if logic to the "Please enter your personal details and billing information to checkout" heading to make it show something like "If you need to update your billing information, please click here, then return to checkout by clicking "Cart" on the navigatio menu" for logged in users

<p>{if !$loggedin}{$LANG.orderForm.enterPersonalDetails}{else}If you need to update your billing information, please <a href="/yourwhmcs/clientarea.php?action=details">click here</a>, then return to checkout by clicking "Cart" on the navigation menu.{/if}</p> 

Now that is more like a "standard" shopping cart.

Edited by startover909
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated