Members
-
PLP_VIEW :String
-
Description
The name of the main view of the PLP component. Use this to refer to the view 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
-
getPagination() → {Pagination}
-
Description
Gets information about the pagination applied in the product list page. Use only after the search page has rendered (by subscribing to the afterShowContent event).
var plp = container.getComponent('PLP'); plp.on("afterShowContent", function() { var pagination = plp.getPagination(); }); // Example of the object returned with getPagination() { "currentPage": 1, "display": "grid", "itemCount": 140, "pageCount": 6, "pageSize": 24, "searchText": "shirt", "sorting": "relevance:desc" }Returns
-
setCurrentPage( page ) → {Deferred}
-
Description
Navigates to the specified page in the result set. This method works only when the current view is the search page. Pages use a one-based index; the first page is "1". The page to navigate to must be less than or equal to the total number of pages. Use getPagination to get the total number of pages.
var plp = container.getComponent('PLP'); plp.setCurrentPage({currentPage: 2}).then(function() { alert("Success"); }, function() { alert("Fail"); });Parameters
Name Type Description pagenumber The page in the result set you want to navigate to.
pagemust be greater than or equal to one, and less than or equal to the total page count. See getPagination.Returns
-
getSorting() → {Sorting}
-
Description
Gets information about the current sorting options. This method works only when the current view is the search page.
var plp = container.getComponent('PLP'); plp.getSorting(); // Example of the object returned with getSorting() { "id": "relevance:desc", "isDefault": false, "name": "Relevance" }Returns
-
getAllSorting() → {Array.<Sorting>}
-
Description
Gets information about all sorting options on the page. This method works only when the current view is the search page, otherwise it returns undefined. To get the current sorting option on the page, use getSorting.
var plp = container.getComponent('PLP'); plp.getAllSorting(); // Example of the array of objects returned with getAllSorting() [ { active: true, id: relevance:desc, name: Relevance, isDefault: true }, { id: onlinecustomerprice:asc", name: "Price, low to high", isDefault: false } ]Returns
-
setSorting( sorting ) → {Deferred}
-
Description
Sets the sorting options of the current search page. This method works only when the current view is the search page. If the sorting option was applied successfully, the product list is updated on the page.
var plp = container.getComponent('PLP'); plp.setSorting({sorting: "onlinecustomerprice:asc"});Parameters
Name Type Description sortingSorting An object with one property
sorting. The value must be a valid sorting option on the page - use getAllSorting to get a list of all available sorting options and then use the value of theidproperty as the value ofsorting.Returns
-
getDisplay() → {Display}
-
Description
Gets information about the current display options, such as the number of columns displayed, the display option ID, and the display option name. This method works only when the current view is the search page.
var plp = container.getComponent('PLP'); plp.getDisplay(); // Example of the object returned by getDisplay() { columns: 2, icon: "icon-display-table", id: "table", isDefault: false, name: "Table", template: "facets_item_cell_table.tpl" }Returns
-
getAllDisplay() → {Array.<Display>}
-
Description
Gets information about all display options, including the current display option. This method works only when the current view is the search page.
Returns
-
setDisplay( options ) → {Deferred}
-
Description
Sets the display options of the product list page. This method works only when the current view is the search page.
Parameters
Name Type Description optionsDisplay Returns
-
getPageSize() → {PageSize}
-
Description
Gets the page size setting of the current page. The page size setting determines the maximum number of items to display per page, for example, 12, 24, or 48. It does not get the number of items currently displayed on the page - use getPagination for that. This method works only when the current view is the search page.
var plp = container.getComponent('PLP'); plp.getPageSize(); // Example of the object returned by getPageSize() { id: "24", isDefault: true, items: 24, name: "$(0) per page" }Returns
-
getAllPageSize() → {Array.<PageSize>}
-
Description
Gets all page size settings of the current page. This method works only when the current view is the search page.
var plp = container.getComponent('PLP'); plp.getAllPageSize(); // Example of the array of objects returned with getAllPageSize() [ { id: "12", isDefault: true, items: 12, name: "$(0) per page" }, { active: true, id: "24", isDefault: true, items: 24, name: "$(0) per page" }, ... ]Returns
-
setPageSize( options ) → {Deferred}
-
Description
Sets the page size setting of the page. This method works only when the current view is the search page.
var plp = container.getComponent('PLP'); plp.setPageSize({pageSize: "12"});Parameters
Name Type Description optionsObject An object with one property
pageSize. The value ofpageSizemust be a valid page size setting ID. Use getAllPageSize to get a list of all page size settings.Returns
-
getFilters() → {Array.<Filter>}
-
Description
Gets information about the filters currently applied on the search page. This method works only when the current view is the search page.
Some filters might be returned in the object
var plp = container.getComponent('PLP'); plp.getFilters(); // Example of the array of objects returned by getFilters(); [ { config: {}, id: "custitem30", isParameter: false, url: "custitem30", value: [ "Small" ] }, { config: {}, id: "custitem40", isParameter: false, url: "custitem40", value: [ "Sportswear" ] } ]Returns
-
getAllFilters() → {Array.<Filter>}
-
Description
Gets information about all filters that can be applied on the search page. One or more of the filters may be active. This method works only when the current view is the search page.
var plp = container.getComponent('PLP'); plp.getAllFilters(); // Example of the array of objects returned by getAllFilters(); [ { id: "custitem30", url: "custitem30", values: [ { displayName: "Small", isActive: false, isImageTile: false, label: "Small", link: "/custitem30/Small" }, { displayName: "Medium", isActive: true, isImageTile: false, label: "Medium", link: "/custitem30/Medium" } ] }, { id: "custitem40", url: "custitem40", values: [ { displayName: "Accessories", isActive: false, isImageTile: false, label: "Accessories", link: "/custitem30/Medium/custitem40/Accessories" }, { displayName: "Outerwear", isActive: false, isImageTile: false, label: "Accessories", link: "/custitem30/Medium/custitem40/Outerwear" } ] } ]Returns
-
setFilters( filters ) → {Deferred}
-
Description
Sets the filters on the product list page.
Parameters
Name Type Description filtersArray.<Filter> An object with one property called
filters.Returns
-
getSearchText() → {String|null}
-
Description
Gets the search text entered by the visitor on the search page. This method works only when the current view is the search page.
var plp = container.getComponent('PLP'); plp.getSearchText();Returns
-
setSearchText( options ) → {Deferred}
-
Description
Sets the search text and performs the search on the current search page.
var plp = container.getComponent('PLP'); plp.getFilters(); plp.setSearchText({searchText: "shirt"});Parameters
Name Type Description optionsObject An object with one property called
searchText. Its value is the search string. If the object is empty, all products are returned in the search.Returns
-
getItemsInfo() → {Array.<SearchItemInfo>}
-
Description
Gets information about all items currently displayed on the product list page.
var plp = container.getComponent('PLP'); plp.getFilters(); plp.getItemsInfo(); // Example of the array of objects returned by getItemsInfo() [ { displayname: "Casual Striped Shirt", internalid: 8034, isinstock: true, itemid: OM5235, onlinecustomerprice: 38.99 quantityavailable: 6, ... }, { displayname: "Casual Chequered Shirt", internalid: 8109, isinstock: true, itemid: OM5337, onlinecustomerprice: 29.99 quantityavailable: 3, ... } ]Returns
-
getCategoryInfo() → {Object}
-
Description
Gets information about the current category, including the parent URL, any sibling categories, and any child categories. This method works only when the view is a category page.
Commerce categories are See Commerce Categories for more information about setting up commerce categories in NetSuite.
var plp = container.getComponent('PLP'); var categoryinfo = plp.getCategoryInfo(); var categoryname = categoryinfo.name; var categorypage = categoryinfo.fullurl; if (categroypage.indexOf("sports") >= 0) { alert("Special offer on all sports clothes and equipment until the end of the month!"); } // Example of the object returned by getCategoryInfo() { addtohead: "", breadcrumb: Array [], categories: [ { name: "Climbing", internalid: "37", sequencenumber: "0", ... }, { name: "Ski", internalid: "38", sequencenumber: "1", ... } ], description: "", fullurl: "/sports", internalid: "35", name: "Sports Clothes and Equipment", pagetitle: "Sports Clothes and Equipment", parenturl: "", ... }Returns
-
getURL( Pagination ) → {String}
-
Description
Gets the Item Search API URL with the current filters and settings of the search page, such as the page size setting (see getPageSize()) or the display options (see getDisplay()). To ensure the URL is correctly formed and uses the current filters, sorting, and pagination, pass a Pagination object as an argument to
getUrl().var plp = container.getComponent('PLP'); var itemsearchurl = plp.getUrl(plp.getPagination); // Example of string returned by getUrl() without a Pagination object. "/api/items?c=1010101&country=US¤cy=USD&fieldset=search&include=facets&language=en&limit=24&n=2&offset=0&pricelevel=5&q=&sort=relevance%3Adesc" // Example of string returned by getUrl() with a Pagination object as an argument. "/api/items?c=1010101&country=US¤cy=USD&fieldset=search&include=facets&language=en&limit=12&n=2&offset=0&pricelevel5.from=20.00&pricelevel5.to=30.00&pricelevel=5&q=&sort=relevance%3Adesc"See Item Search API for more information about the item search API.
Parameters
Name Type Description PaginationPagination 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