new CheckoutComponent()

Description

The CheckoutComponent lets you manage the steps in the checkout flow. For example, you can get the current checkout step, go to the next or previous steps, and add or remove steps in the checkout flow. Get an instance of this component by calling container.getComponent("Checkout").

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


getCurrentStep() → {Deferred.<CheckoutStep>}

Description

Gets the current checkout step.

Returns

Returns a Deferred object. If the promise is resolved, it returns a CheckoutStep. If the promise is rejected, it returns an error. Use the .then() and .fail() methods to work with the resolved and rejected state of the object.

Use this method only after the checkout page has rendered - you can listen for the afterShowContent event to do this. Otherwise, this method returns undefined.

 checkout.on("afterShowContent", function() {
			     checkout.getCurrentStep().then(function(step))
			 })

setCurrentStep( step ) → {Deferred.<CheckoutStep>}

Description

Sets the current checkout step.

Parameters
Name Type Description
step CheckoutStep
Returns

Returns a Deferred object. If the promise is resolved, it indicates the operation was successful. If the promise is rejected, it returns an error.


getStepGroupsInfo() → {Deferred.<Array.<CheckoutStepGroup>>}

Description

Gets the step groups in the checkout flow.

Returns

Returns a Deferred object. If the promise is then resolved, it returns an array of CheckoutStepGroup. If the promise is rejected, it returns an error.


getStepsInfo() → {Deferred.<Array.<CheckoutStep>>}

Description

Gets the steps in the checkout flow.

Returns

Returns a Deferred object. If the promise is then resolved, it returns an array of CheckoutStep. If the promise is rejected, it returns an error.


getCheckoutFlow() → {String}

Description

Gets the name of the current checkout flow, as specified on the SuiteCommerce Configuration page in NetSuite.

Returns

addModuleToStep( data ) → {Deferred}

Description

Adds a module to a step. You must extend class WizardModule to add a new module.

EXAMPLE

checkout.addModuleToStep( {
			    step_url: 'shipping/new_step'
			,    module: {
			        id: 'new_module'
			    ,    index: 0
			    ,    classname: 'OrderWizard.Module.Shipmethod'
			    ,    options: { container: '#wizard-step-content-right'}
			    }
			})
Parameters
Name Type Description
data AddModuleData
Returns

Returns a Deferred object. If the promise is resolved, it indicates the operation was successful. If the promise is rejected, it returns an error.


removeModuleFromStep( data ) → {Deferred}

Description

Removes a module from a step.

Parameters
Name Type Description
data RemoveModuleData
Returns

Returns a Deferred object. If the promise is resolved, it indicates the operation was successful. If the promise is rejected, it returns an error.


addStepsGroup( data ) → {Deferred.<CheckoutStepGroup>}

Description

Adds a steps group.

Parameters
Name Type Description
data AddStepGroupData
Returns

Returns a Deferred object. If the promise is then resolved, it returns a CheckoutStepGroup. If the promise is rejected, it returns an error.


removeStepsGroup( data ) → {Deferred}

Description

Removes a steps group.

Parameters
Name Type Description
data RemoveStepGroupData
Returns

Returns a Deferred object. If the promise is resolved, it indicates the operation was successful. If the promise is rejected, it returns an error.


addStep( data ) → {Deferred.<CheckoutStep>}

Description

Adds a step to a steps group.

Parameters
Name Type Description
data AddStepData
Returns

Returns a Deferred object. If the promise is then resolved, it returns a CheckoutStep. If the promise is rejected, it returns an error.


removeStep( step_url ) → {Deferred}

Description

Removes a step from a steps group.

Parameters
Name Type Description
step_url String
Returns

Returns a Deferred object. If the promise is resolved, it indicates the operation was successful. If the promise is rejected, it returns an error.


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


beforeAddModuleToStep


afterAddModuleToStep


beforeSetCurrentStep


afterSetCurrentStep


beforeAddStep


afterAddStep


beforeAddStepsGroup


afterAddStepsGroup