Announcement

Collapse
No announcement yet.

Customer Login - page and redirect variables

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Customer Login - page and redirect variables

    I am working on the a block of code that will display the following on my header:
    Hello, Guest ( Login or Register)

    I am using the following template blocks:

    Code:
    <!--START: login--> 
      <p>Hello, Guest (<a href="login.asp">Login</a> or <a href="register.asp">Register</a>)</p>
    <!--END: login-->
    I have two outcomes that I would like to happen:
    1. When a customer clicks on the login link, the system will go to a page that allows the customer to login to the system and then route them back to the page they were on when they clicked the login link.
    2. When a customer clicks on the register link, the system will go to a page that allows the customer to register for an account and then route them back to the page they were on when they clicked the register link.


    Any ideas how to do this?

    thanks in advance.
    Jeff

    The Wedding Printer

  • #2
    This is possible for the login page. I have not found a way to do it on the registration page, because that does not seem to carry URL parameters through to the confirmation page. If you discover a way, please post.

    I use this on product pages.
    Link to login:
    Code:
    [store_secure_url]/myaccount.asp?returnurl=product.asp?itemid=[itemid]
    In login-account.html:
    At the top:
    Code:
    <script type="text/javascript">
    /* Extracts ?foo=bar attributes from URL. Used to read "returnurl" and add to form */
    function getUrlVars() {
        var vars = {};
        var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
            vars[key] = encodeURI(value);
        });
        return vars;
    }
    </script>

    At the bottom:

    Code:
    <script type="text/javascript">
    /* Looks for "returnurl" variable in request URL. If found then add it to the returnurl input of the login form */
    	var returnURLVar = getUrlVars()["returnurl"];
    	if (returnURLVar != undefined) {
    		document.getElementById("myReturnURL").value = returnURLVar;
    	}
    </script>
    Add this to the login form:

    Code:
    <input type="hidden" name="returnurl" id="myReturnURL" value="">
    So the top script will look for a return URL passed in the current page address and put it into a variable, properly format. After the page loads it will look to see if that variable is being used and if so put it into the value of the hidden input. When you submit the form 3DCart will return you to the value of "returnurl"

    You could combine this into one code block instead of two but I kinda did this off the cuff.

    Let me know if you need clarification.

    Comment


    • #3
      After a little bit of research, you could fairly easily do this for the registration page, too. You would need to use javascript to store the variable of the return URL and use Session Variables to have them persist between page loads.

      Comment


      • #4
        I had not thought of using javascript. Previous carts I have used had this as base functionality.

        One question on this code snippet:
        Originally posted by cbsteven View Post
        I use this on product pages.
        Link to login:
        Code:
        [store_secure_url]/myaccount.asp?returnurl=product.asp?itemid=[itemid]
        I was planning on using this in my frame.html page. This would require the returnurl to be dynamically defined by page. Is there a global variable that shows this or will I have to create javascript for this function?

        jeff
        Jeff

        The Wedding Printer

        Comment


        • #5
          my plans for implementation on something very similar to this will be to use a modal box to display the registration form and its necessary information. Have you thought of that? No page redirect needed

          Comment


          • #6
            Originally posted by jcocking View Post


            I was planning on using this in my frame.html page. This would require the returnurl to be dynamically defined by page. Is there a global variable that shows this or will I have to create javascript for this function?

            jeff
            You will need to use javascript to read the current window address. Should only be one or two lines of code.

            Comment


            • #7
              Originally posted by jleclair View Post
              my plans for implementation on something very similar to this will be to use a modal box to display the registration form and its necessary information. Have you thought of that? No page redirect needed
              Do you have the code block to do a login? When I have tried, it places me on a message.asp page.

              jeff
              Jeff

              The Wedding Printer

              Comment


              • #8
                Originally posted by cbsteven View Post
                You will need to use javascript to read the current window address. Should only be one or two lines of code.
                Here is the code I used:

                Code:
                      <p>Hello, Guest 
                <script language = javascript>
                document.write('<a href = "myaccount.asp?returnurl=' + location.href +  '" class="link">');
                </script>
                        login</a> or <a href="register.asp" class="link">Register</a></p>
                Jeff

                The Wedding Printer

                Comment


                • #9
                  For the LOGIN page, If you set the value of the returnurl in the for to "true" then it'll redirect automatically to the page set as the HTTP REFERRER.

                  So,

                  Code:
                  <input type="hidden" name="returnurl" id="myReturnURL" value="true">
                  Jimmy

                  Comment


                  • #10
                    Originally posted by jimmy3dcart View Post
                    For the LOGIN page, If you set the value of the returnurl in the for to "true" then it'll redirect automatically to the page set as the HTTP REFERRER.

                    Hmm, I can't get this to work. Just tried it from a category page and it just takes me to the my account page after logging in.

                    I will leave the value as true. Maybe you will get a chance to try it out to check.

                    Comment


                    • #11
                      Originally posted by cbsteven View Post
                      Hmm, I can't get this to work. Just tried it from a category page and it just takes me to the my account page after logging in.

                      I will leave the value as true. Maybe you will get a chance to try it out to check.
                      If you place the login code within an individual page and use the following hidden variable of returnurl with a setting of true, you will be logged in and returned to the referring page.

                      Code:
                      <form action="login.asp" method="post">
                         <strong>[CustomerInfo_email]:</strong><input type="text" size="20" name="email" value="">
                         <strong>[CustomerInfo_password]:</strong><input type="password" size="20" name="password">
                         <input type="hidden" name="returnurl" id="myReturnURL" value="true">
                         <input type="submit" value="[login_button]" class="btn">
                      </form>
                      You can use this code block in the frame.html as a constant element or use it as a modal design element.
                      Jeff

                      The Wedding Printer

                      Comment

                      Working...
                      X