new LoginRegisterComponent()

Description

The LoginRegister component lets you create listeners for events that occur on the Log In / Register page in a web store. It also lets you capture additional information from the login or register form when a web store visitor logs in or registers.

You can listen for the following events on the Log In / Register page. The 'before' events let you interrupt the login or registration process, do something else (such as validate input data or call an external API), and depending on the outcome, either cancel the event or let the event complete.

  • beforeLogin - A cancelable event that occurs before login is completed.
  • beforeRegister - A cancelable event that occurs before registration is completed.
  • afterRegister - A cancelable event that occurs after registration is completed.

To capture field input from the login or registration forms, the LoginRegister component utilizes placeholders in the default base theme templates. The placeholders are positioned below the last field in each form. Here are the template files in which you can find the relevant placeholders:


FormTemplate FilePlaceholder
Loginlogin_register_login.tpl<div data-view="Login.CustomFields"></div>
Registerlogin_register_register.tpl<div data-view="Register.CustomFields"></div>

Get an instance of this component by calling container.getComponent('LoginRegisterPage');

Note: This class has no methods.

Details

SuiteCommerce 2019.1

Members


componentName :String

Description

A unique name that identifies the component. Use the component name when getting a component, for example, application.getComponent(componentName).

Details
String

application :ComponentContainer

Description

The name which identify this kind of component. This name is used both for registering a new component and
getting a component implementation with ComponentContainer

Details

Methods


setChildViewIndex( view_id, placeholder_selector, view_name, index ) → {void}

Description

Changes the position of a child view inside a container.

Parameters
Name Type Description
view_id string

The identifier of the view of the current component that contains the child view whose position will be changed.

placeholder_selector string

The identifier of a location in the specified view (view_id) where the child view will be added.

view_name string

The identifier of a view in the placeholder.

index number

The index of the child view's position.

Returns

Returns null if the operation is successful. Otherwise, it throws an exception.

Throws
Details

addChildViews( view_id, child_views ) → {void}

Description

Adds one or more child views to an existing view. The existing view must already be in the DOM and must have the 'data-view' HTML attribute.

The addChildViews method is flexible, but more complex than addChildView. Use the simpler addChildView where possible.

EXAMPLE

checkout.addChildViews(
			    checkout.WIZARD_VIEW
			    , {
			        'Wizard.StepNavigation':
			        {
			            'CheckoutView':
			            {
			                childViewIndex: 1
			            ,   childViewConstructor: function ()
			                {
			                    return new CheckoutExtensionView({checkout:checkout});
			                }
			            }
			        }
			    }
			);
Parameters
Name Type Description
view_id string

The identifier of the view of the current component to which the child views will be added.

child_views object
Returns

Returns null if the operation is successful. Otherwise, it throws an exception.

Throws
Details

addChildView( view_id, childViewConstuctor ) → {void}

Description

Adds a child view to an existing View which is already appended in the DOM with the given data-view HTML attribute.

EXAMPLE

checkout.addChildView('Wizard.StepNavigation', function () {
			    return new CheckoutExtensionView({checkout:checkout});
			});
Parameters
Name Type Description
view_id string

The identifier of the view of the current component to which the child view will be added.

childViewConstuctor SimpleChildViewConstructor

The identifier of the location in the specified view (view_id) where the child view will be added.

Returns

Returns null if the operation is successful. Otherwise, it throws an exception.

Throws
Details

removeChildView( view_id, placeholder_selector [, view_name ] ) → {void}

Description

Removes a child view from a view.

Parameters
Name Type Attributes Description
view_id string

The identifier of the view of the current component from which the child view will be removed.

placeholder_selector string

The identifier of the location in the specified view (view_id) from which the child view will be removed.

view_name string <optional>

The identifier of the view to be removed.

Returns

Returns null if the operation is successful. Otherwise, it throws an exception.

Throws
Details

addToViewContextDefinition( view_id, property_name, type, callback ) → {void}

Description

Adds a property to the UI context of a view to extend interaction with its template.

Parameters
Name Type Description
view_id string

The identifier of the view of the current component to which the context property will be added.

property_name string

The name of the property.

type string

The type of the property. The value returned by the callback function must be of the same type.

callback function

A function that sets the value of the property (property_name).

Returns

Returns null if the operation is successful. Otherwise, it throws an exception.

Throws

removeToViewContextDefinition( view_id, property_name ) → {void}

Description

Removes a property from the UI context of a view.

Parameters
Name Type Description
view_id string

The identifier of the view of the current component from which the context property will be removed.

property_name string

The name of the property.

Returns

Returns null if the operation is successful. Otherwise, it throws an exception.

Throws

addToViewEventsDefinition( view_id, event_selector, callback ) → {void}

Description

Adds an event handler to an event in a view.

Parameters
Name Type Description
view_id string

The identifier of the view of the current component to which the event handler will be added.

event_selector string
callback function

The event handler function to call when the specified event occurs.

Returns

Returns null if the operation is successful. Otherwise, it throws an exception.

Throws

removeToViewEventsDefinition( view_id, event_selector ) → {void}

Description

Removes an event handler from an event in a view.

Parameters
Name Type Description
view_id string

The identifier of the view of the current component to which the event handler will be added.

event_selector string
Returns

Returns null if the operation is successful. Otherwise, it throws an exception.

Throws

extend( componentDefinition ) → {BaseComponent}

Description

Extends the current component and creates a child component.

Parameters
Name Type Description
componentDefinition Object

An object with the appropriate properties and methods to create the component.

Returns
Details

on( event_name, handler ) → {void}

Description

Attaches an event handler to an event name. Alias for CancelableEvents#cancelableOn.

Parameters
Name Type Description
event_name String

The name of the event to attach to

handler function
Returns
Details

off( event_name, handler ) → {void}

Description

Detaches an event handler from an event name. Alias for CancelableEvents#cancelableOff.

Parameters
Name Type Description
event_name String

The name of the event from which to detach the event handler.

handler function
Returns
Details

cancelableOn( event_name, handler ) → {void}

Description

Attaches an event handler to an event.

Parameters
Name Type Description
event_name String

The name of the event to which the event handler will be attached.

handler function

The event handler method that will be invoked when event_name is triggered. This function can receive optionally one parameter representing the action parameter. Besides optionally can return a Deferred to details the execution of the trigger's callback. If the returned Deferred is rejected the trigger's callback wont be called

Returns
Details

cancelableOff( event_name, handler ) → {void}

Description

Detaches an event handler from an event.

Parameters
Name Type Description
event_name String

The name of the event from which to detach the event handler. This argument is required.

handler function

The event handler that will be removed from the list of handlers attached to the event. This argument is required.

Returns
Details

cancelableDisable( event_name ) → {void}

Description

Disables all the event handlers attached to an event.

Parameters
Name Type Description
event_name String

The name of the event.

Returns
Details

cancelableEnable( event_name ) → {Void}

Description

Re-enables all the event handlers attached to an event.

Parameters
Name Type Description
event_name String

The name of the event.

Returns
Details

cancelableTrigger( event_name, ...args ) → {Deferred}

Description

Triggers an event with a set of arguments. If an event handler is rejected, the event handler callbacks will not be executed.

Parameters
Name Type Attributes Description
event_name String

The name of the event to trigger.

args params <repeatable>

One or more arguments that will be broadcast to all event handlers attached to the event.

Returns

Returns a Deferred object. Because event handlers are sometimes asynchronous, any callbacks in the event handlers will also be asynchronous.

Details

cancelableTriggerUnsafe( event_name, ...args ) → {Deferred}

Description

Triggers an event with a set of unsanitized arguments. If an event handler is rejected, the event handler callbacks will not be executed.

Parameters
Name Type Attributes Description
event_name String

The name of the event to trigger.

args params <repeatable>

One or more arguments that will be broadcast to all event handlers attached to the event.

Returns

Returns a Deferred object. Because event handlers are sometimes asynchronous, any callbacks in the event handlers will also be asynchronous.

Events


beforeLogin

Description

A cancelable event triggered before a user is logged in. The event occurs after the Log In button is clicked and before any data is sent to the NetSuite backend. Login data is passed to the event as an object with the following structure:

{
			     email: "johnsmith@example.com",
			     password: "password",
			     redirect: true
			}

If there are custom fields on the login form, they are passed as additional properties of the object. For example, if a two-factor authentication code field is included on the login form and the value of its name attribute is twofacode, the object will include a property called twofacode.
Note: With the beforeLogin event, data from custom fields is discarded and is not saved in NetSuite.

{
			     email: "johnsmith@example.com",
			     password: "password",
			     redirect: true,
			     twofacode: "123456"
			}

beforeRegister

Description

A cancelable event triggered before a visitor is registered in the system. The event occurs after the Register button is clicked and before any data is sent to the NetSuite backend. Registration data is passed to the event as an object with the following structure:

{
			firstname: "John",
			lastname: "Smith",
			company: "NetSuite",
			email: "johnsmith@example.com",
			password: "123-abc-*&%",
			password2: "123-abc-*&%",
			emailsubscribe: "T"
			 }

If there are custom fields on the registration form, they are passed as additional properties of the object. The data from custom fields are persisted in NetSuite, provided the corresponding custom field records exist in the system. The field names on the registration form must match the internal ID of the fields in NetSuite.


afterRegister

Description

A cancelable event triggered after registration has been completed successfully. If you use the afterRegister event, you must explicitly redirect to the registration success page or to another landing page.

In the following example, the web store visitor is redirected to a different URL if the value of the custom field custentity_vatno starts with the string DE.

var loginRegisterPageComponent = container.getComponent('LoginRegisterPage');
			
			if (loginRegisterPageComponent) {
			     loginRegisterPageComponent.on('afterRegister', function(formFields) {
			
			         if (formFields.custentity_vatno.indexOf('DE') == 0) {
			             location.href = 'https://example.com/de/';
			         }
			         else {
			             location.href = 'https://example.com/';
			         }
			     })
			}