netsuitesuitescriptsuitecommerce

Netsuite's SuiteCommerce Advance:: Social SignUp(FaceBook, Google+)


I need to integrate Social Sign-up/Login in our SuiteCommerce Advance Site, Anyone knows ho we can do that? Help would be Appreciates. Our SuiteCommerce verion is Vension 2016.


Solution

  • I managed to do this after searching for 1 days you need to make change only for login and register page

    Register With Facebook--> This simply will use FB details paste it on current input boxes and auto click on submit button

    File Path--> LoginRegister@2.2.0/Templates/login_register_register.tpl

    Code-->

    <!-- Code Button to get The Login With Fb -->
    <fb:login-button scope="public_profile,email" id="facebook-reg" onlogin="checkLoginState();">
    Sign Up With Facebook
    </fb:login-button>
    
    <script>
      function statusChangeCallback(response) {
        if (response.status === 'connected') {
          GetFbUserDetails();
        } else if (response.status === 'not_authorized') {
          document.getElementById('status').innerHTML = 'Please log ' +
            'into this app.';
        } else {
          document.getElementById('status').innerHTML = 'Please log ' +
            'into Facebook.';
        }
      }
      function checkLoginState() {
            document.getElementById("fblogin").innerHTML="Processing..";
        FB.getLoginStatus(function(response) {
          statusChangeCallback(response);
        });
      }
      window.fbAsyncInit = function()
        {
      FB.init({
        appId      : 'your-app-id',
        cookie     : true,  // enable cookies to allow the server to access
                            // the session
        xfbml      : true,  // parse social plugins on this page
        version    : 'v2.6' // use graph api version 2.8
      });
      FB.getLoginStatus(function(response)
        {
        statusChangeCallback(response);});
      };
    
        (function(d, s, id){
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/en_US/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));
    
      function GetFbUserDetails()
        {
                FB.api('/me?fields=id,email,first_name,last_name', function(response)
                {
                         var fname = document.getElementById('register-firstname');
                         fname.value = response.first_name;
    
                         var lname = document.getElementById('register-lastname');
                         lname.value = response.last_name;
    
                         var email = document.getElementById('register-email');
                         email.value = response.email;
    
                         var pass = document.getElementById('register-password');
                         pass.value = response.id;
    
                         var pass2 = document.getElementById('register-password2');
                         pass2.value = response.id;
                         if(pass!=="" && pass2!=="")
                         {
                            document.getElementById('facebook').click();
                         }
        }  );
    }
    

    Login With Facebook--> You can use same code to get this done..

    Let me know Your comments on this