Wednesday, November 14, 2018

Create Logout/Login Link for a WSDK Web Store


Currently the link to Login from an External Catalog is static and the mechanism to make it dynamic to determine whether a visitor is logged in already is not available yet. The following instruction is an alternate solution in creating a dynamic Login/Logout link.

Prerequisite: Knowledge in HTML and JavaScript

A. Prepare a logout HTML file

1. Open an HTML file
2. Add the following script in the Addition to <head>




3. Navigate to Documents> Files> File Cabinet
4. Upload the HTML file in the File Cabinet, either the Web Site Hosting Folder for the web store or the Images folder
5. Edit the file uploaded
6. Copy any URL available for the file

B. Add a custom script in the pages hosted outside of NetSuite

1. Add the following sample script in each of your non-NetSuite hosted web site page or in an include file

NOTES:

* The __getcustomermessage container contains the 'Script to recognize and welcome the current customer' from the list of 'Links from your site back into NetSuite'
* It is a required content which you can get under Setup> Site Builder > Preview Web Site
* You can apply a style/CSS to that container to be hidden if preferred not to show

* The __login_logout container will display the link to either login or logout, this is controlled through the rest of the script
* The __LOGIN_LINK variable should contain the login link you can copy in either 'Link to customer login page' from the list of 'Links from your site back into NetSuite'
* The __LOGOUT_LINK variable should contain the link copied from Step A.6
* Make sure that both values for __LOGIN_LINK and __LOGOUT_LINK are wrapped in a pair of quotations as in the example
* Customizing the Login and Logout links are in the section where there is a comment

* This just serve as a sample alternate solution while the out-of-the-box feature is not available yet
* This can be customized or further optimized depending on the need

No comments:

Post a Comment