Members
-
PDP_FULL_VIEW :String
-
Description
The name of the main PDP full view. Use this name to reference views in methods such as addChildViews, addToViewContextDefinition, and so on.
-
PDP_QUICK_VIEW :String
-
Description
The name of the PDP quick view. Use this name to reference views in methods such as addChildViews, addToViewContextDefinition, and so on.
-
componentName :String
-
Description
A unique name that identifies the component. Use the component name when getting a component, for example,
application.getComponent(componentName).Details
-
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 ComponentContainerDetails
Methods
-
getAllMatrixChilds() → {Array.<MatrixChild.ItemInfo>}
-
Description
Gets all the subitems of a matrix item.
getAllMatrixChildsreturns an array of objects. Each object in the array is a subitem of the matrix item.The following example shows how to use the method and what a simplified version of an object in the array might look like.
var pdp = container.getComponent('PDP'); var iteminfo = pdp.getAllMatrixChilds(); // Example of an object in the array returned by getAllMatrixChilds() [ { "internalid": 7040, "isbackorderable": true, "isinstock": true, "itemid": "SHIRT-COT-S", "quantityavailable": 4, ... } ]Returns
-
getItemInfo() → {ItemInfo}
-
Description
Gets information about the item in the current product details page (PDP), which may include details such as the item quantity, shipping address, or fulfillment choice. Information may also include data from custom fields. The actual values returned will depend on how the item is configured in NetSuite. This method only works if the current view is a PDP.
The following example shows how to use this method and what a simplified version of the object returned might look like.
var pdp = container.getComponent('PDP'); var iteminfo = pdp.getItemInfo(); // Example of the object returned from getItemInfo() { "item": { "displayname": "Cotton Shirt", "internalid": 7101, "isinstock": true, "quantityavailable": 8, ... }, "options": [ { "cartOptionId": "custcol14", "itemOptionId": "custitem30", "label": "Size", "values": [ { "internalid": "2", "label": "Small" }, { "internalid": "4", "label": "Medium" } ] } ], "quantity": "1" }You can use dot notation to access the object properties. Here is an explanation of some of the properties from the example above:
- item.internalid - The internal ID of the item in NetSuite.
- item.isinstock - Indicates if inventory is available.
- options.cartOptionId - The name of an option on the product details page. Use the value of this property as the first argument in
setOption()when setting an option. - options.values.internalid - The internal ID of the option value. Use the value of this property as the second argument in
setOption()when setting an option. - options.values.label - The label of the option as it appears on the product details page.
Returns
-
getSelectedMatrixChilds( matrix_options ) → {Array.<MatrixChild.ItemInfo>}
-
Description
Gets the subitems of a matrix item according to the filters defined in
matrix_options. Ifmatrix_optionsis set but empty, this method returns all subitems of the matrix item. Ifmatrix_optionsis null or undefined, this method returns the subitems of the current selection.Parameters
Name Type Description matrix_optionsMatrixOptionSelection The options by which to filter the subitems of the matrix item. If you omit `matrix_options', an array of all subitems is returned.
Returns
-
setOption( cart_option_id, value ) → {Deferred.<Boolean>}
-
Description
Sets an option of the current product details page. This method only works if the current view is a PDP.
You need to pass two arguments to this method:
cart_option_id- The ID of the option you want to set. You can get a list of all possiblecart_option_ids by calling getItemInfo() first. getItemInfo() returns an object that contains anoptionsproperty, which contains an array with one object. Each object in the array corresponds to an option that can be set. Use the value of thecartOptionIdproperty in the object as thecart_option_idargument in setOption().value- The value of the option you want to set. You can get a list of all possible optionvalues by calling getItemInfo() first. getItemInfo() returns an object that contains anoptionsproperty, which contains an array with one object. Thevaluesproperty in the object contains an array of objects, each of which corresponds to an option value. Use the value of theinternalidproperty in the object as thevalueargument in setOption().
In the following example, the size option of an item is set to medium. The size option is represented by the
cart_option_idwith the valuecustcol14. To set the size to medium, we pass '4', which is theinternalidfor the medium size of the item.var pdp = container.getComponent('PDP'); var iteminfo = pdp.getItemInfo(); pdp.setOption('custcol14', '4');Parameters
Name Type Description cart_option_idString The option identifier. You can get a list of option identifiers with getItemInfo().
valueString The value of the option. Leave the
valueblank or provide an invalid value to clear the option.Returns
Fires
-
setQuantity( quantity ) → {Deferred}
-
Description
Updates the quantity of the item on the product details page. For example, if the quantity is currently 2 and you call
setQuantity(4), the quantity is changed to 4. This method only works if the current view is a PDP.var pdp = container.getComponent('PDP'); var newquantity = 2; pdp.on('beforeQuantityChange', function(event) { if (!_.isNumber(newquantity)) { alert('That is not a valid quantity.'); return false; } });Parameters
Name Type Description quantityNumber The quantity of the item to set. Quantity must be a positive integer (greater than zero).
Returns
Fires
-
getStockInfo() → {Item.StockInfo}
-
Description
Gets information about the inventory of the item, such as whether the item is in stock, the quantity in stock, and the in-stock and out-of-stock messages. If the item is an inventory item, it returns the available quantity of the item. If the item is a matrix item and subitems are filtered (with getSelectedMatrixChilds()), it returns the sum of the available quantity of all the filtered subitems of the matrix item.
If the Store Pickup feature is enabled in the NetSuite account (see Store Pickup), this method also returns the quantity of inventory available for store pickup at each pickup location. The
stockPerLocationproperty of the main object contains an array of objects, each of which contains the ID of the store pickup location and the quantity available.var pdp = container.getComponent('PDP'); var stockinfo = pdp.getStockInfo(); var totalstock = stockinfo.stock; var isinstock = stockinfo.isInStock;Returns
-
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_idstring The identifier of the view of the current component that contains the child view whose position will be changed.
placeholder_selectorstring The identifier of a location in the specified view (view_id) where the child view will be added.
view_namestring The identifier of a view in the placeholder.
indexnumber The index of the child view's position.
Returns
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_idstring The identifier of the view of the current component to which the child views will be added.
child_viewsobject Returns
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-viewHTML attribute.EXAMPLE
checkout.addChildView('Wizard.StepNavigation', function () { return new CheckoutExtensionView({checkout:checkout}); });Parameters
Name Type Description view_idstring The identifier of the view of the current component to which the child view will be added.
childViewConstuctorSimpleChildViewConstructor The identifier of the location in the specified view (view_id) where the child view will be added.
Returns
Throws
Details
-
removeChildView( view_id, placeholder_selector [, view_name ] ) → {void}
-
Description
Removes a child view from a view.
Parameters
Name Type Attributes Description view_idstring The identifier of the view of the current component from which the child view will be removed.
placeholder_selectorstring The identifier of the location in the specified view (view_id) from which the child view will be removed.
view_namestring <optional> The identifier of the view to be removed.
Returns
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_idstring The identifier of the view of the current component to which the context property will be added.
property_namestring The name of the property.
typestring The type of the property. The value returned by the callback function must be of the same type.
callbackfunction A function that sets the value of the property (property_name).
Returns
Throws
Details
-
removeToViewContextDefinition( view_id, property_name ) → {void}
-
Description
Removes a property from the UI context of a view.
Parameters
Name Type Description view_idstring The identifier of the view of the current component from which the context property will be removed.
property_namestring The name of the property.
Returns
Throws
Details
-
addToViewEventsDefinition( view_id, event_selector, callback ) → {void}
-
Description
Adds an event handler to an event in a view.
Parameters
Name Type Description view_idstring The identifier of the view of the current component to which the event handler will be added.
event_selectorstring callbackfunction The event handler function to call when the specified event occurs.
Returns
Throws
Details
-
removeToViewEventsDefinition( view_id, event_selector ) → {void}
-
Description
Removes an event handler from an event in a view.
Parameters
Name Type Description view_idstring The identifier of the view of the current component to which the event handler will be added.
event_selectorstring Returns
Throws
Details
-
extend( componentDefinition ) → {BaseComponent}
-
Description
Extends the current component and creates a child component.
Parameters
Name Type Description componentDefinitionObject 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_nameString The name of the event to attach to
handlerfunction 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_nameString The name of the event from which to detach the event handler.
handlerfunction Returns
Details
-
cancelableOn( event_name, handler ) → {void}
-
Description
Attaches an event handler to an event.
Parameters
Name Type Description event_nameString The name of the event to which the event handler will be attached.
handlerfunction 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_nameString The name of the event from which to detach the event handler. This argument is required.
handlerfunction 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_nameString 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_nameString 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_nameString The name of the event to trigger.
argsparams <repeatable> One or more arguments that will be broadcast to all event handlers attached to the event.
Returns
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_nameString The name of the event to trigger.
argsparams <repeatable> One or more arguments that will be broadcast to all event handlers attached to the event.
Returns
Details
Events
-
beforeOptionSelection
-
Description
Cancelable event triggered before an option is set. See CancelableEvents.
Properties
Name Type Description optionCartIdString The selected option id
valueString The selected option value
-
afterOptionSelection
-
Description
Event triggered after an option is set.
Properties
Name Type Description optionCartIdString The selected option id
valueString the selected option value
-
beforeQuantityChange
-
Description
Cancelable event triggered before the quantity is changed. See CancelableEvents.
-
afterQuantityChange
-
Description
Event triggered after the quantity is changed.
-
beforeImageChange
-
Description
Cancelable event triggered before the main image displayed on the product details page is changed. See CancelableEvents.
Properties
Name Type Description currentIndexnumber nextIndexnumber -
afterImageChange
-
Description
Event triggered after the main image displayed on the product details page is changed.