Customer Name / Registration Field on Shopping Cart

General ShopSite user discussion

Customer Name / Registration Field on Shopping Cart

Postby adsol » Tue Feb 15, 2011 11:24 pm

Sorry to keep bugging everyone. We are in the process of redesigning our core templates for our client's so they can use some of the new features of the latest version. Needless to say some odds and ends are popping up and we need a little clarification on some things.

Anyway... here is the problem. On the shopping cart page (the actual cart) we have something like this:

Code: Select all
[-- IF SignedIn? --]
<!-- USER IS IN -->
Welcome back [-- RegisteredName --]! For account settings...........
[-- ELSE --]
    [-- IF SC_Registration --]
        [-- IF SC_Must_Register --]
             You Must Register to Order!
        [-- ELSE --]
             Registration on but not reqired for checkout
        [--END_IF--]
    [-- ELSE --]
        # Do nothing (Reg is not on or required.)
    [--END_IF--]
[--END_IF--]


Problem is we get "Welcome back ! For account settings...." No name prints out. Registration is on. The name is there. I can call the name on the CR pages using [--CR_Customer_Name --]. It just won't load into the cart.

I have also called [-- RegisteredName --] outside the IF blocks and still nothing despite being logged in.

Ideas?
adsol
 
Posts: 15
Joined: Tue Mar 10, 2009 1:28 pm

Re: Customer Name / Registration Field on Shopping Cart

Postby Jim » Wed Feb 16, 2011 6:46 am

Is the domain name the same for the cart as it is for the store pages? Can't read cookies from different domain.
Are cookies and javascript enabled in your browser?
Have you included the required javascript to read the cookie? [-- SC_JavaScript Extras --]
Is this a Pro store? (starter and manager don't have registration)
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Customer Name / Registration Field on Shopping Cart

Postby adsol » Wed Feb 16, 2011 12:49 pm

Jim wrote:Is the domain name the same for the cart as it is for the store pages? Can't read cookies from different domain.
Are cookies and javascript enabled in your browser?
Have you included the required javascript to read the cookie? [-- SC_JavaScript Extras --]
Is this a Pro store? (starter and manager don't have registration)


- it is SS 10sp2 Pro
- [-- SC_JavaScript Extras --] are included.
- Domain name is the same (SSL does not turn on until past this page)
- JS and cookies are on.
- Registration is on
- I can login and I get the welcome back message but no name.

All other functions of the cart work. The [-- RegisteredName --] field returns a blank or null value as looking at the resulting HTML code shows no data being written.

Does SS write the name to the page where [-- RegisteredName --] is called or it write a JS block to get the cookie and write the name? I ask because [-- RegisteredName --] adds no code to the page.
adsol
 
Posts: 15
Joined: Tue Mar 10, 2009 1:28 pm

Re: Customer Name / Registration Field on Shopping Cart

Postby adsol » Wed Feb 16, 2011 1:23 pm

I still am not sure why this field is not working... but I have found a workaround.

After Jim mentioned cookies, I went poking around in my cookies to see what exactly SS was storing. I figured that it would be a client or database id of some sort. What I found was that SS is indeed storing the actual name of the customer and thus accessing it is a breeze!

I wrote a little script to retrieve the value. It works perfectly.

Here is my code:

Code: Select all
<script type="text/javascript">
// THIS SCRIPT GETS THE USER'S NAME OF THE SIGNED IN USER
// THEN PRINTS IT TO THE SCREEN
function DisplayUserName(cookiename) {

  // DEFINE VARIABLES
  var startSTR = document.cookie.indexOf(cookiename + "=");
  var endSTR = "";
  var mynameSTR= "";

  // MAKE SURE VALUE IS SET
  if (startSTR != -1) {
    // GET START OF NAME (add one to remove =)
    startSTR = document.cookie.indexOf("=", startSTR) +1;
    // GET END OF NAME (delimiter | )
    endSTR = document.cookie.indexOf("|", startSTR);
   
    // MAKE SURE NAME IS STILL THERE
    if (endSTR != -1) {
      // SET FINAL (remove one to remove |)
      mynameSTR = unescape(document.cookie.substring(startSTR,endSTR -1));
    
      // Display the name
      document.write(mynameSTR);
    }
  }
}
DisplayUserName("[-- RegCookieName --]");
</script>
adsol
 
Posts: 15
Joined: Tue Mar 10, 2009 1:28 pm

Re: Customer Name / Registration Field on Shopping Cart

Postby Jim » Wed Feb 16, 2011 2:51 pm

I checked with the engineer and he looked at the the code. The [-- registeredname --] tag is not valid on the shopping cart screen, it is only valid on customer registration screens. His reasoning was that the tag [-- SC_Registration --] displays the shoppers name if they are logged in (along with links to their account and signout) and if the shopper is not logged in but has been before it displays the name with "You are no longer signed in" and links to sign in or register.

I looked through all the ShopSite templates for the tag [-- RegisteredName --] and can not find a single instance where it is used. Perhaps it was a tag that was implemented early on but superceded by the [-- SC_Registration --] and [-- RegistrationSignIn --] tags. Both of which output the users name as well as the links for signing in, signing out or registering depending on what screen the shopper is on and if they are logged in or not.

I will have the documentation updated to reflect this.

I'm glad you found a work-around.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Customer Name / Registration Field on Shopping Cart

Postby adsol » Wed Feb 16, 2011 4:01 pm

Thanks Jim. I was poking around in the SS help documentation to see what new fields were available and see what types of new attributes we could add and saw the [-- RegisteredName --] listed under shopping cart and said... "Hmm that would make a nice customized welcome, lets use it!"

I was tearing my hair out trying to figure out why it was not doing anything. :lol:

Thanks for the assistance!
adsol
 
Posts: 15
Joined: Tue Mar 10, 2009 1:28 pm

Re: Customer Name / Registration Field on Shopping Cart

Postby Jim » Wed Feb 16, 2011 4:47 pm

I did some experimenting to see where it will actually work.
These worked and displayed the name --Customer Registration screens, Gift Certificate, Billing (2nd cart screen) , Confirmation (3rd cart screen), Thank You

These either gave an error or displayed nothing -- Pages, Moreinfo pages, Include files, Search, First shopping cart screen, Tell-a-Friend

I think getting the data from the cookie is the best solutions.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah


Return to User Forum

Who is online

Users browsing this forum: No registered users and 69 guests