0

I am trying to create a custom "View Cart" through SSP application. And i want to check if customer is currently logged in or not, and try to get customer information. Unfortunately, it is always returning false.

I am pretty sure, my account is logged in because i can access my Custom Center page.

I even tried in SS file. What seems to be the problem here? Thank you for any help. Any other way of checking it in SSP and SS?

SSP File :

  <html>
  <head>
  <%=getPageFullHead()%>
  <link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
  <script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
  <%  var container = nlapiGetWebContainer(),
      session = container.getShoppingSession(),
      orders = session.getOrder(),
      orderSummaryTotal = orders.getOrderSummary();
  %>
 </head>
 <body>
   <div><%=session.isLoggedIn()%></div>
 </body>
 </html>

SS File :

  function service(request, response) {

    var session = nlapiGetWebContainer().getShoppingSession(),
        orders = session.getOrder(),
        isLoggedIn = session.isLoggedIn();

           response.setContentType('JSON');
       response.write(JSON.stringify(isLoggedIn));

  }

Tried also viewing the object in console console.log(<%=JSON.stringify(session)%>), but it gives me error like this

"Please login first before this operation."

Damiko Gutom
  • 31
  • 1
  • 5

1 Answers1

1

In the world of NetSuite there are methods to retrieve logged in:

  1. isLoggedIn() requires secure https and an active session (logged-in user)
  2. getCurrentAttribute works on http and expired sessions (recognized, logged-out user).

For example, use the following to get customer information on the non-secure, SSP cart.

<%=getCurrentAttribute('customer','firstname')%>
<%=getCurrentAttribute('customer','lastname')%>
<%=getCurrentAttribute('customer','companyname')%>
<%=getCurrentAttribute('site','name')%>
<%=getCurrentAttribute('customer','currency')%>
<%=getCurrentAttribute('customer','category')%>
Zoro-Alforque
  • 81
  • 1
  • 5