menu

SFRA / Server-side JS / Global

Members

Template

This script creates a base implementation to handle configurable theming options within SFRA. It is an extensible anchor point for more elaborate implementations and can be overwritten by plugins and custom implementation

Source:

Methods

addLineItem(currentBasket, product, quantity, childProducts, optionModel, defaultShipment) β†’ {dw.order.ProductLineItem}

Adds a line item for this product to the Cart

Parameters:
Name Type Description
currentBasket dw.order.Basket
product dw.catalog.Product
quantity number

Quantity to add

childProducts Array.<string>

the products' sub-products

optionModel dw.catalog.ProductOptionModel

the product's option model

defaultShipment dw.order.Shipment

the cart's default shipment method

Source:
Returns:
  • The added product line item
Type
dw.order.ProductLineItem

addProductToCart(currentBasket, productId, quantity, childProducts, options) β†’ {Object}

Adds a product to the cart. If the product is already in the cart it increases the quantity of that product.

Parameters:
Name Type Description
currentBasket dw.order.Basket

Current users's basket

productId string

the productId of the product being added to the cart

quantity number

the number of products to the cart

childProducts Array.<string>

the products' sub-products

options Array.<SelectedOption>

product options

Source:
Returns:

returns an error object

Type
Object

addRefinementValues(search, preferences)

Updates the search model with the preference refinement values

Parameters:
Name Type Description
search dw.catalog.SearchModel

SearchModel instance

preferences Object

Query params map

Source:

addResource(resourceArray, src, integrity)

If the resource to add is not already in the resource array then add it to the array

Parameters:
Name Type Description
resourceArray Array

Either the scripts or styles array to which you want to add the resource src to.

src string

URI of the resource to add

integrity string

cryptographic hash of a resource

Source:

allBundleItemsSame(productLineItems, childProducts) β†’ {boolean}

Determines whether provided Bundle items are in the list of submitted bundle item IDs

Parameters:
Name Type Description
productLineItems dw.util.Collection.<dw.order.ProductLineItem>

Bundle item IDs currently in the Cart

childProducts Array.<string>

List of bundle items for the submitted Bundle under consideration

Source:
Returns:
  • Whether provided Bundle items are in the list of submitted bundle item IDs
Type
boolean

appendQueryParams(target, queryParamsToAppend) β†’ {string}

Appends query params to a URL

Parameters:
Name Type Description
target string

An URL endpoint with or without query params e.g. http://someresource or http://someresource?xyz=123

queryParamsToAppend Object | Array.<string>

Object or list of query params strings with or without resource path prepended, where resource path is discarded e.g., ['xyz=123'] or ['http://someresource?xyz=123'] or { var1: val1, var2: val2 }

Source:
Returns:
  • Target URL appended with query params from sourceQueryString
Type
string

appendRenderings(renderings, object) β†’ {void}

Stores a list of rendering steps.

Parameters:
Name Type Description
renderings Array

The array of rendering steps

object Object

An object containing what type to render

Source:
Returns:
Type
void

applicablePaymentCards(paymentCards) β†’ {Array}

Creates an array of objects containing applicable credit cards

Parameters:
Name Type Description
paymentCards dw.util.Collection.<dw.order.PaymentCard>

An ArrayList of applicable payment cards that the user could use for the current basket.

Source:
Returns:

Array of objects that contain information about applicable payment cards for current basket.

Type
Array

applicablePaymentMethods(paymentMethods) β†’ {Array}

Creates an array of objects containing applicable payment methods

Parameters:
Name Type Description
paymentMethods dw.util.ArrayList.<dw.order.dw.order.PaymentMethod>

An ArrayList of applicable payment methods that the user could use for the current basket.

Source:
Returns:

of object that contain information about the applicable payment methods for the current cart

Type
Array

applyCache(res)

Set the cache values

Parameters:
Name Type Description
res Object

The response object

Source:

applyDefaultCache(req, res, next) β†’ {void}

Applies the default expiration value for the page cache.

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

next function

Next call in the middleware chain

Source:
Returns:
Type
void

applyInventorySensitiveCache(req, res, next) β†’ {void}

Applies the inventory sensitive page cache.

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

next function

Next call in the middleware chain

Source:
Returns:
Type
void

applyPromotionSensitiveCache(req, res, next) β†’ {void}

Applies the default price promotion page cache.

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

next function

Next call in the middleware chain

Source:
Returns:
Type
void

applyRenderings(res) β†’ {void}

Determines what to render

Parameters:
Name Type Description
res Object

Response object

Source:
Returns:
Type
void

applyShortPromotionSensitiveCache(req, res, next) β†’ {void}

Applies the default price promotion page cache.

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

next function

Next call in the middleware chain

Source:
Returns:
Type
void

Authorize(orderNumber, paymentInstrument, paymentProcessor) β†’ {Object}

Authorizes a payment using a credit card. Customizations may use other processors and custom logic to authorize credit card payment.

Parameters:
Name Type Description
orderNumber number

The current order's number

paymentInstrument dw.order.PaymentInstrument

The payment instrument to authorize

paymentProcessor dw.order.PaymentProcessor

The payment processor of the current payment method

Source:
Returns:

returns an error object

Type
Object

Authorize() β†’ {Object}

default hook if no payment processor is supported

Source:
Returns:

an object that contains error information

Type
Object

backButtonDetection(clickStream) β†’ {string}

check to see if we are coming back from a pdp, if yes, use the old qs to set up the grid refinements and number of tiles

Parameters:
Name Type Description
clickStream Object

object with an array of request to the server in the current session

Source:
Returns:
  • url to redirect to
Type
string

calculatePaymentTransaction(currentBasket) β†’ {Object}

Sets the payment transaction amount

Parameters:
Name Type Description
currentBasket dw.order.Basket

The current basket

Source:
Returns:

an error object

Type
Object

calculateTaxes(basket) β†’ {Object}

Calculate sales taxes

Parameters:
Name Type Description
basket dw.order.Basket

current basket

Source:
Returns:
  • object describing taxes that needs to be applied
Type
Object

calculateTaxes(basket) β†’ {Response}

Calculate sales taxes

Parameters:
Name Type Description
basket dw.order.Basket

current basket

Source:
Returns:
  • An object that contains calculated taxes and custom properties
Type
Response

calculateTotals(basket)

Calculate all totals as well as shipping and taxes

Parameters:
Name Type Description
basket dw.order.Basket

current basket

Source:

categoryToObject(category) β†’ {Object}

Converts a given category from dw.catalog.Category to plain object

Parameters:
Name Type Description
category dw.catalog.Category

A single category

Source:
Returns:

plain object that represents a category

Type
Object

checkBundledProductCanBeAdded(childProducts, productLineItems, quantity) β†’ {boolean}

Check if the bundled product can be added to the cart

Parameters:
Name Type Description
childProducts Array.<string>

the products' sub-products

productLineItems dw.util.Collection.<dw.order.ProductLineItem>

Collection of the Cart's product line items

quantity number

the number of products to the cart

Source:
Returns:
  • return true if the bundled product can be added
Type
boolean

checkIfAddressStored(address, storedAddresses) β†’ {boolean}

Verify if the address already exists as a stored user address

Parameters:
Name Type Description
address dw.order.OrderAddress

Object that contains shipping address

storedAddresses Array.<Object>

List of stored user addresses

Source:
Returns:
  • Boolean indicating if the address already exists
Type
boolean

checkParams(name, middlewareChain) β†’ {void}

Validate that first item is a string and all of the following items are functions

Parameters:
Name Type Description
name string

Arguments that were passed into function

middlewareChain Array

middleware chain

Source:
Returns:
Type
void

computedPageMetaData(req, res, next) β†’ {void}

Middleware to compute request pageMetaData object

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

next function

Next call in the middleware chain

Source:
Returns:
Type
void

concat(…arguments) β†’ {dw.util.ArrayList}

concat method for dw.util.Collection subclass instances

Parameters:
Name Type Attributes Description
arguments dw.util.Collection <repeatable>

first collection to concatinate

Source:
Returns:

ArrayList containing all passed collections

Type
dw.util.ArrayList

Middleware to use consent tracking check

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

next function

Next call in the middleware chain

Source:
Returns:
Type
void

copyBillingAddressToBasket(address, currentBasket)

Copies a raw address object to the baasket billing address

Parameters:
Name Type Description
address Object

an address-similar Object (firstName, ...)

currentBasket Object

the current shopping basket

Source:

copyCustomerAddressToBilling(address)

Copies a CustomerAddress to a Basket as its Billing Address

Parameters:
Name Type Description
address dw.customer.CustomerAddress

The customer address

Source:

copyCustomerAddressToShipment(address, shipmentOrNullopt)

Copies a CustomerAddress to a Shipment as its Shipping Address

Parameters:
Name Type Attributes Description
address dw.customer.CustomerAddress

The customer address

shipmentOrNull dw.order.Shipment <optional>

The target shipment

Source:

copyObjectToForm(object, currentForm)

Copy the values of an object to form

Parameters:
Name Type Description
object Object

the object to set the new form values to

currentForm dw.web.Form | dw.web.FormGroup

Form to be parsed

Source:

copyShippingAddress(address) β†’ {Object}

Copy dwscript address object into JavaScript object

Parameters:
Name Type Description
address dw.order.OrderAddress

Address to be copied

Source:
Returns:
  • Plain object that represents an address
Type
Object

copyShippingAddressToShipment(shippingData, shipmentOrNullopt)

Copies information from the shipping form to the associated shipping address

Parameters:
Name Type Attributes Description
shippingData Object

the shipping data

shipmentOrNull dw.order.Shipment <optional>

the target Shipment

Source:

countBonusProducts(item) β†’ {number}

Generates the count of the discount line item to determine if it is full

Parameters:
Name Type Description
item dw.order.BonusDiscountLineItem

a product line item

Source:
Returns:

the total number of bonus products from within one bonus discount line item

Type
number

createAddressObject(addressObject) β†’ {Object}

creates a plain object that contains address information

Parameters:
Name Type Description
addressObject dw.order.OrderAddress

User's address

Source:
Returns:

an object that contains information about the users address

Type
Object

createCategorySearchRefinement(productSearch, refinementDefinition, Model) β†’ {Array}

Creates an array of category refinements for category search

Parameters:
Name Type Description
productSearch dw.catalog.ProductSearchModel

Product search object

refinementDefinition dw.catalog.ProductSearchRefinementDefinition

Refinement definition for which we wish to retrieve refinement values for

Model CategoryAttributeValue

model of the category class

Source:
Returns:
  • List of categories
Type
Array

createDiscountObject(collection, discounts) β†’ {Object}

Adds discounts to a discounts object

Parameters:
Name Type Description
collection dw.util.Collection

a collection of price adjustments

discounts Object

an object of price adjustments

Source:
Returns:

an object of price adjustments

Type
Object

createGeoLocationObject(storesObject) β†’ {Array}

Creates an array of objects containing the coordinates of the store's returned by the search

Parameters:
Name Type Description
storesObject dw.util.Set

a set of <dw.catalog.Store> objects

Source:
Returns:

an array of coordinates objects with store info

Type
Array

createOrder(currentBasket) β†’ {dw.order.Order}

Attempts to create an order from the current basket

Parameters:
Name Type Description
currentBasket dw.order.Basket

The current basket

Source:
Returns:

The order object created from the current basket

Type
dw.order.Order

createProductLineItemsObject(allLineItems, view) β†’ {Array}

Creates an array of product line items

Parameters:
Name Type Description
allLineItems dw.util.Collection.<dw.order.ProductLineItem>

All product line items of the basket

view string

the view of the line item (basket or order)

Source:
Returns:

an array of product line items.

Type
Array

createProductSearchRefinement(productSearch, refinementDefinition, refinementValues, Model) β†’ {Array}

Creates an array of category refinements for category search

Parameters:
Name Type Description
productSearch dw.catalog.ProductSearchModel

Product search object

refinementDefinition dw.catalog.ProductSearchRefinementDefinition

Refinement definition for which we wish to retrieve refinement values for

refinementValues dw.util.Collection.<dw.catalog.ProductSearchRefinementValue>

Collection of refinement values

Model CategoryAttributeValue

model of the category class

Source:
Returns:
  • List of categories
Type
Array

createStoresObject(storesObject) β†’ {Array}

Creates an array of objects containing store information

Parameters:
Name Type Description
storesObject dw.util.Set

a set of <dw.catalog.Store> objects

Source:
Returns:

an array of objects that contains store information

Type
Array

createStoresResultsHtml(storesInfo) β†’ {string}

create the stores results html

Parameters:
Name Type Description
storesInfo Array

an array of objects that contains store information

Source:
Returns:

The rendered HTML

Type
string

createToken() β†’ {string}

Creates a token. This should be replaced by utilizing a tokenization provider

Source:
Returns:

a token

Type
string

EE(fn, context, onceopt)

Representation of a single EventEmitter function.

Parameters:
Name Type Attributes Default Description
fn function

Event handler to be called.

context Mixed

Context for function execution.

once Boolean <optional>
false

Only emit once

Source:

emptyAddress(shipment) β†’ {boolean}

Returns a boolean indicating if the address is empty

Parameters:
Name Type Description
shipment dw.order.Shipment

A shipment from the current basket

Source:
Returns:

a boolean that indicates if the address is empty

Type
boolean

ensureAllShipmentsHaveMethods(basket)

Loops through all Shipments and attempts to select a ShippingMethod, where absent

Parameters:
Name Type Description
basket dw.order.Basket

the target Basket object

Source:

ensureNoEmptyShipments(req)

Ensures that no shipment exists with 0 product line items

Parameters:
Name Type Description
req Object

the request object needed to access session.privacyCache

Source:

ensureShipmentHasMethod(shipment)

Sets the default ShippingMethod for a Shipment, if absent

Parameters:
Name Type Description
shipment dw.order.Shipment

the target Shipment object

Source:

ensureValidShipments(lineItemContainer) β†’ {boolean}

Loop through all shipments and make sure all not null

Parameters:
Name Type Description
lineItemContainer dw.order.LineItemCtnr

Current users's basket

Source:
Returns:
  • allValid
Type
boolean

every(collection, callback) β†’ {boolean}

Determines whether every list item meets callback's truthy conditional

Parameters:
Name Type Description
collection dw.util.Collection

Collection subclass instance to map over

callback function

Callback function for each item

Source:
Returns:
  • Whether every list item meets callback's truthy conditional
Type
boolean

excludeUuid(selectedUuid, itemUuid) β†’ {boolean}

Sets a flag to exclude the quantity for a product line item matching the provided UUID. When updating a quantity for an already existing line item, we want to exclude the line item's quantity and use the updated quantity instead.

Parameters:
Name Type Description
selectedUuid string

Line item UUID to exclude

itemUuid string

Line item in-process to consider for exclusion

Source:
Returns:
  • Whether to include the line item's quantity
Type
boolean

find(array, matcher) β†’ {Object|undefined}

Returns a value of the first element in the array that satisfies the provided testing function. Otherwise undefined is returned.

Parameters:
Name Type Description
array Array

Array of elements to find the match in.

matcher Array

function that returns true if match is found

Source:
Returns:

element that matches provided testing function or undefined.

Type
Object | undefined

find(collection, match, scopeopt) β†’ {Object|null}

Find method for dw.util.Collection subclass instance

Parameters:
Name Type Attributes Description
collection dw.util.Collection

Collection subclass instance to find value in

match function

Match function

scope Object <optional>

Optional execution scope to pass to the match function

Source:
Returns:

Single item from the collection

Type
Object | null

findValue(formGroup, name) β†’ {Object}

Get values of a formGroup to object

Parameters:
Name Type Description
formGroup dw.web.FormGroup

Form group

name string

The name of the formGroup

Source:
Returns:

Object with nested values

Type
Object

first(collection) β†’ {Object|null}

Gets the first item from dw.util.Collection subclass instance

Parameters:
Name Type Description
collection dw.util.Colleciton

Collection subclass instance to work with

Source:
Returns:

First element from the collection

Type
Object | null

forEach(collection, callback, scopeopt) β†’ {void}

forEach method for dw.util.Collection subclass instances

Parameters:
Name Type Attributes Description
collection dw.util.Collection

Collection subclass instance to map over

callback function

Callback function for each item

scope Object <optional>

Optional execution scope to pass to callback

Source:
Returns:
Type
void

formatCurrency(value, currencyCode) β†’ {string}

Returns the string representation of an amount, using specified currencyCode/countryCode

Parameters:
Name Type Description
value number

the currency value

currencyCode string

the currency code

Source:
Returns:

formatted currency string

Type
string

formatNumber(value) β†’ {number}

formats a given number

Parameters:
Name Type Description
value number

number that needs formatting

Source:
Returns:

formatted number

Type
number

formatPrice(value) β†’ {number}

formats a given price

Parameters:
Name Type Description
value number

price that needs formatting

Source:
Returns:

formatted price

Type
number

formField(field) β†’ {Object}

Function to conver <dw.web.FormField> object to plain JS object.

Parameters:
Name Type Description
field dw.web.FormField

original formField object.

Source:
Returns:

Plain JS object representing formField.

Type
Object

fraudDetection(order) β†’ {Object}

fraud detection hook

Parameters:
Name Type Description
order dw.order.Order

The order object to be placed

Source:
Returns:

an error object. Status can have three values 'success', 'fail' or 'flag' error code that could be mapped to localized resources error Message a string with the error message, that could be used as a fall-back if error code doesn't have a mapping

Type
Object

gatherShippingAddresses(order) β†’ {Array}

Gather all addresses from shipments and return as an array

Parameters:
Name Type Description
order dw.order.Basket

current order

Source:
Returns:
  • Array of shipping addresses
Type
Array

generateAddressName(address) β†’ {string}

Generate address name based on the full address object

Parameters:
Name Type Description
address dw.order.OrderAddress

Object that contains shipping address

Source:
Returns:
  • String with the generated address name
Type
string

generateToken(req, res, next) β†’ {void}

Middleware generating a csrf token and setting the view data

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

next function

Next call in the middleware chain

Source:
Returns:
Type
void

get(productSearch, refinementDefinition, refinementValues) β†’ {Array}

Retrieve refinement values based on refinement type

Parameters:
Name Type Description
productSearch dw.catalog.ProductSearchModel

Product search object

refinementDefinition dw.catalog.ProductSearchRefinementDefinition

Refinement definition for which we wish to retrieve refinement values for

refinementValues dw.util.Collection.<dw.catalog.ProductSearchRefinementValue>

Collection of refinement values

Source:
Returns:
  • List of refinement values
Type
Array

get(req, res, next) β†’ {void}

Middleware filter for get requests

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

next function

Next call in the middleware chain

Source:
Returns:
Type
void

getAccountModel(req) β†’ {Object}

Creates an account model for the current customer

Parameters:
Name Type Description
req Object

local instance of request object

Source:
Returns:

a plain object of the current customer's account

Type
Object

getAccountOpenReportingURLs(registeredCustomerCount) β†’ {Array}

Build the urls that report on account open

Parameters:
Name Type Description
registeredCustomerCount number

The number of registered customers in the system

Source:
Returns:
  • an array of urls that are used to report
Type
Array

getAddresses(addressBook) β†’ {Array.<Object>}

Creates an array of plain object that contains address book addresses, if any exist

Parameters:
Name Type Description
addressBook Object

target customer

Source:
Returns:

an array of customer addresses

Type
Array.<Object>

getAddressFromRequest(req) β†’ {Object}

Retrieve raw address JSON object from request.form

Parameters:
Name Type Description
req Request

the DW Request object

Source:
Returns:
  • raw JSON representing address form data
Type
Object

getAddressObject(address) β†’ {Object}

Translates global customer's preferredAddress into local object

Parameters:
Name Type Description
address Object

a CustomerAddress or OrderAddress

Source:
Returns:

local instance of address object

Type
Object

getAllAttrValues(variationModel, selectedValue, attr, endPoint, selectedOptionsQueryParams, quantity) β†’ {Array.<Object>}

Retrieve all attribute values

Parameters:
Name Type Description
variationModel dw.catalog.ProductVariationModel

A product's variation model

selectedValue dw.catalog.ProductVariationAttributeValue

Selected attribute value

attr dw.catalog.ProductVariationAttribute

Attribute value'

endPoint string

The end point to use in the Product Controller

selectedOptionsQueryParams string

Selected options query params

quantity string

Quantity selected

Source:
Returns:
  • List of attribute value objects for template context
Type
Array.<Object>

getAllBreadcrumbs(cgid, pid, breadcrumbs) β†’ {Array}

Creates the breadcrumbs object

Parameters:
Name Type Description
cgid string

category ID from navigation and search

pid string

product ID

breadcrumbs Array

array of breadcrumbs object

Source:
Returns:

an array of breadcrumb objects

Type
Array

getApplicableShippingMethods(shipment, addressopt) β†’ {dw.util.Collection}

Plain JS object that represents a DW Script API dw.order.ShippingMethod object

Parameters:
Name Type Attributes Description
shipment dw.order.Shipment

the target Shipment

address Object <optional>

optional address object

Source:
Returns:

an array of ShippingModels

Type
dw.util.Collection

getAppliedPromotions(lineItem) β†’ {Array.<Object>|undefined}

get the promotions applied to the product line item

Parameters:
Name Type Description
lineItem dw.order.ProductLineItem

API ProductLineItem instance

Source:
Returns:

an array of objects containing the promotions applied to the product line item.

Type
Array.<Object> | undefined

getApproachingDiscounts(basket, discountPlan) β†’ {Object}

Generates an object of approaching discounts

Parameters:
Name Type Description
basket dw.order.Basket

Current users's basket

discountPlan dw.campaign.DiscountPlan

set of applicable discounts

Source:
Returns:

an object of approaching discounts

Type
Object

getAssociatedAddress(basket, customer) β†’ {string|boolean}

Returns the matching address ID or UUID for a billing address

Parameters:
Name Type Description
basket dw.order.Basket

line items model

customer Object

customer model

Source:
Returns:

returns matching ID or false

Type
string | boolean

getAssociatedAddress(shipment, customer) β†’ {string|boolean}

Returns the matching address ID or UUID for a shipping address

Parameters:
Name Type Description
shipment dw.order.Shipment

line items model

customer Object

customer model

Source:
Returns:

returns matching ID or false

Type
string | boolean

getAttributeRefinementValueModel(refinementDefinition) β†’ {Object}

Retrieves attribute refinement value model

Parameters:
Name Type Description
refinementDefinition dw.catalog.ProductSearchRefinementDefinition

Refinement definition for which we wish to retrieve refinement values for

Source:
Returns:
  • Attribute refinement value model module
Type
Object

getAttributes(attributeModel) β†’ {Object|null}

Creates an object of the visible attributes for a product

Parameters:
Name Type Description
attributeModel dw.catalog.ProductAttributeModel

attributeModel for a given product.

Source:
Returns:

an object containing the visible attributes for a product.

Type
Object | null

getAttrResetUrl(values, attrID) β†’ {string}

Gets the Url needed to relax the given attribute selection, this will not return anything for attributes represented as swatches.

Parameters:
Name Type Description
values Array

Attribute values

attrID string

id of the attribute

Source:
Returns:

-the Url that will remove the selected attribute.

Type
string

getBannerImageUrl(category) β†’ {string}

Retrieves banner image URL

Parameters:
Name Type Description
category dw.catalog.Category

Subject category

Source:
Returns:
  • Banner's image URL
Type
string

getBasketOpenReportingURLs(currentBasket) β†’ {Array}

Build the urls that report on the order

Parameters:
Name Type Description
currentBasket dw.order.Basket

the basket object

Source:
Returns:
  • an array of urls that are used to report on the current basket
Type
Array

getBonusUnitPrice(apiProduct, duuid) β†’ {string}

returns the price of the bonus product

Parameters:
Name Type Description
apiProduct dw.catalog.Product

Product information returned by the script API

duuid string

discount line item UUID

Source:
Returns:
  • returns the price of the bonus product
Type
string

getBonusUnitPrice(lineItem, product) β†’ {string}

returns the price of the bonus product line item

Parameters:
Name Type Description
lineItem dw.order.ProductLineItem

API ProductLineItem instance of the embedded bonus product line item

product dw.catalog.Product

qualifying product.

Source:
Returns:

result the price of the bonus product

Type
string

getBundledProductLineItems(bundledProductLineItems, productFactory) β†’ {Array}

creates an array of bundled line items

Parameters:
Name Type Description
bundledProductLineItems dw.util.Collection

Collection of products in the bundle

productFactory Object

Factory utility that returns a ProductModel instance

Source:
Returns:

an array of bundled line items

Type
Array

getBundledProducts(apiProduct, quantity, factory) β†’ {Array.<Object>}

Convert bundled products to models

Parameters:
Name Type Description
apiProduct dw.catalog.Product

Product returned by the API

quantity number

selected quantity

factory Object

Product Factory object

Source:
Returns:
  • returns an array of bundle product models
Type
Array.<Object>

getCartActionUrls() β†’ {Object}

Generates an object of URLs

Source:
Returns:

an object of URLs in string format

Type
Object

getCategoryTemplate(apiProductSearch) β†’ {string}

Retrieve a category's template filepath if available

Parameters:
Name Type Description
apiProductSearch dw.catalog.ProductSearchModel

API search instance

Source:
Returns:
  • Category's template filepath
Type
string

getCategoryUrl(category) β†’ {string}

Get category url

Parameters:
Name Type Description
category dw.catalog.Category

Current category

Source:
Returns:
  • Url of the category
Type
string

getCheckoutReportingURLs(UUID, step, stepName) β†’ {Array}

Build the urls that report on the checkout

Parameters:
Name Type Description
UUID string

the target basket's uuid

step number

the step in the checkout

stepName string

the name of the step in checkout

Source:
Returns:
  • an array of urls that are used to report
Type
Array

getCheckoutStepInformation(lineItemContainer) β†’ {Object}

Creates an object of information that contains information about the steps

Parameters:
Name Type Description
lineItemContainer dw.order.LineItemCtnr

Current users's basket

Source:
Returns:

Creates an object that contains information about the checkout steps

Type
Object

getConfig(apiProduct, params) β†’ {Object}

Get information for model creation

Parameters:
Name Type Description
apiProduct dw.catalog.Product

Product from the API

params Object

Parameters passed by querystring

Source:
Returns:
  • Config object
Type
Object

getContentSearchPageJSON(pageElements) β†’ {Array}

Transforms a page of content into an array of JSON objects

Parameters:
Name Type Description
pageElements Object

PagingModel page of content

Source:
Returns:
  • page of content JSON objects
Type
Array

getCurrentLocale(locale, currency) β†’ {Object}

Retrieves session locale info

Parameters:
Name Type Description
locale string

Session locale code, xx_XX

currency dw.util.Currency

Session currency

Source:
Returns:
  • Session locale info
Type
Object

getCurrentOptionModel(optionModel, selectedOptions) β†’ {dw.catalog.ProductOptionModel}

Provides a current option model by setting selected option values

Parameters:
Name Type Description
optionModel dw.catalog.ProductOptionModel

Product's option model

selectedOptions Array.<SelectedOption>

Options selected in UI

Source:
Returns:
  • Option model updated with selected options
Type
dw.catalog.ProductOptionModel

getCustomerObject(customer) β†’ {Object}

Translates global customer object into local object

Parameters:
Name Type Description
customer dw.customer.Customer

Global customer object

Source:
Returns:

local instance of customer object

Type
Object

getCustomerPaymentInstruments(userPaymentInstruments) β†’ {Object}

Creates a plain object that contains payment instrument information

Parameters:
Name Type Description
userPaymentInstruments Object

current customer's paymentInstruments

Source:
Returns:

object that contains info about the current customer's payment instruments

Type
Object

getDefaultOptions(optionModel, options) β†’ {Array.<string>}

Retrieve product's options and default values

Parameters:
Name Type Description
optionModel dw.catalog.ProductOptionModel

A product's option model

options dw.util.Collection.<dw.catalog.ProductOption>

A product's configured options

Source:
Returns:
  • Product line item options
Type
Array.<string>

getDetailsObject(paymentForm) β†’ {Object}

Creates an object from form values

Parameters:
Name Type Description
paymentForm Object

form object

Source:
Returns:

a plain object of payment instrument

Type
Object

getDiscountLineItems(UUID) β†’ {number}

Generates an object of URLs

Parameters:
Name Type Description
UUID string

product line item uuid

Source:
Returns:

the total number of bonus products from within one bonus discount line item

Type
number

getDiscounts(lineItemContainer) β†’ {Array}

creates an array of discounts.

Parameters:
Name Type Description
lineItemContainer dw.order.LineItemCtnr

the current line item container

Source:
Returns:

an array of objects containing promotion and coupon information

Type
Array

getDiscountsHtml(discounts) β†’ {string}

create the discount results html

Parameters:
Name Type Description
discounts Array

an array of objects that contains coupon and priceAdjustment information

Source:
Returns:

The rendered HTML

Type
string

getExistingProductLineItemInCart(product, productId, productLineItems, childProducts, options) β†’ {dw.order.ProductLineItem}

Filter the product line item matching productId and has the same bundled items or options in the cart

Parameters:
Name Type Description
product dw.catalog.Product

Product object

productId string

Product ID to match

productLineItems dw.util.Collection.<dw.order.ProductLineItem>

Collection of the Cart's product line items

childProducts Array.<string>

the products' sub-products

options Array.<SelectedOption>

product options

Source:
Returns:
  • get the first product line item matching productId and has the same bundled items or options
Type
dw.order.ProductLineItem

getExistingProductLineItemsInCart(product, productId, productLineItems, childProducts, options) β†’ {Array.<dw.order.ProductLineItem>}

Filter all the product line items matching productId and has the same bundled items or options in the cart

Parameters:
Name Type Description
product dw.catalog.Product

Product object

productId string

Product ID to match

productLineItems dw.util.Collection.<dw.order.ProductLineItem>

Collection of the Cart's product line items

childProducts Array.<string>

the products' sub-products

options Array.<SelectedOption>

product options

Source:
Returns:
  • Filtered all the product line item matching productId and has the same bundled items or options
Type
Array.<dw.order.ProductLineItem>

getExpirationYears() β†’ {List}

Creates a list of expiration years from the current year

Source:
Returns:

a plain list of expiration years from current year

Type
List

getFirstApplicableShippingMethod(methods, filterPickupInStore) β†’ {dw.order.ShippingMethod}

Returns the first shipping method (and maybe prevent in store pickup)

Parameters:
Name Type Description
methods dw.util.Collection

Applicable methods from ShippingShipmentModel

filterPickupInStore boolean

whether to exclude PUIS method

Source:
Returns:
  • the first shipping method (maybe non-PUIS)
Type
dw.order.ShippingMethod

getFirstNonDefaultShipmentWithProductLineItems(currentBasket) β†’ {dw.order.Shipment}

Returns the first non-default shipment with more than one product line item

Parameters:
Name Type Description
currentBasket dw.order.Basket

The current Basket

Source:
Returns:
  • the shipment
Type
dw.order.Shipment

getFirstProductLineItem(productLineItemsModel) β†’ {Object}

Returns the first productLineItem from a collection of productLineItems.

Parameters:
Name Type Description
productLineItemsModel Object

line items model

Source:
Returns:

returns an object with image properties

Type
Object

getFormData(items, qs) β†’ {Object}

Retrieves and normalizes form data from httpParameterMap

Parameters:
Name Type Description
items dw.web.httpParameterMap

original parameters

qs Object

Object containing querystring

Source:
Returns:

Object containing key value pairs submitted from the form

Type
Object

getFormErrors(form) β†’ {Object}

get form errors and add them to an object

Parameters:
Name Type Description
form Object

the target product line item

Source:
Returns:
  • an object that contain the error in the form
Type
Object

getGeolocationObject(request) β†’ {Object}

get a local instance of the geo location object

Parameters:
Name Type Description
request Object

Global request object

Source:
Returns:

object containing geo location information

Type
Object

getGoogleMapsApi(apiKey) β†’ {string|Null}

If there is an api key creates the url to include the google maps api else returns null

Parameters:
Name Type Description
apiKey string

the api key or null

Source:
Returns:

return the api

Type
string | Null

getHtmlContext(keyMap) β†’ {dw.util.HashMap}

Creates a HashMap input object for dw.util.Template.render(HashMap)

Parameters:
Name Type Description
keyMap Object

Key-value pairs object

Source:
Returns:
  • HashMap from key-value pairs
Type
dw.util.HashMap

getImageUrl(product) β†’ {string}

Get Image URL

Parameters:
Name Type Description
product dw.catalog.Product

Suggested product

Source:
Returns:
  • Image URL
Type
string

getIndividualProducts(apiProduct, factory) β†’ {Array.<Object>}

Parameters:
Name Type Description
apiProduct dw.catalog.Product

Product returned by the API

factory Object

Product Factory object

Source:
Returns:
  • Array of sub-product models
Type
Array.<Object>

getIsSelected(shippingMethod, shipment) β†’ {boolean}

Returns isSelected property for a specific Shipment / ShippingMethod pair

Parameters:
Name Type Description
shippingMethod dw.order.ShippingMethod

the default shipment of the current basket

shipment dw.order.Shipment

a shipment of the current basket

Source:
Returns:

true is shippingMethod is selected in Shipment

Type
boolean

getItemPromoReportingURLs(productLineItem, reportingURLs) β†’ {Array}

get item promo reporting urls

Parameters:
Name Type Description
productLineItem dw.order.ProductLineItem

the target product line item

reportingURLs Array

current array of reporting urls

Source:
Returns:
  • an array of urls
Type
Array

getLastOrder(req) β†’ {Object}

Creates an order model for the current customer

Parameters:
Name Type Description
req Object

the request object

Source:
Returns:

an object of the customer's last order

Type
Object

getLineItemOptionNames(optionProductLineItems) β†’ {Array.<string>}

Retrieve product's options default selected values, id and name from product line item

Parameters:
Name Type Description
optionProductLineItems dw.util.Collection.<dw.order.ProductLineItem>

Option product line items

Source:
Returns:
  • Product line item option display values, id and name
Type
Array.<string>

getLineItemOptions(optionProductLineItems, productId) β†’ {Array.<string>}

Retrieve product's options and default selected values from product line item

Parameters:
Name Type Description
optionProductLineItems dw.util.Collection.<dw.order.ProductLineItem>

Option product line items

productId string

Line item product ID

Source:
Returns:
  • Product line item options
Type
Array.<string>

getList(customerNo) β†’ {List}

Creates a list of address model for the logged in user

Parameters:
Name Type Description
customerNo string

customer number of the current customer

Source:
Returns:

a plain list of objects of the current customer's addresses

Type
List

getListingPageSchema(productIds) β†’ {Object}

Get product listing page schema information

Parameters:
Name Type Description
productIds List

Product Ids

Source:
Returns:
  • Listing Schema object
Type
Object

getListPrice(priceModel) β†’ {dw.value.Money}

Get list price for a product

Parameters:
Name Type Description
priceModel dw.catalog.ProductPriceModel

Product price model

Source:
Returns:
  • List price
Type
dw.value.Money

getListPrices(hit, getSearchHit) β†’ {Object}

Get list price for a given product

Parameters:
Name Type Description
hit dw.catalog.ProductSearchHit

current product returned by Search API.

getSearchHit function

function to find a product using Search API.

Source:
Returns:
  • price for a product
Type
Object

returns object needed to render links to change the locale of the site

Parameters:
Name Type Description
allowedLocales string

list of allowed locales for the site

siteId string

id of the current site

currentLocaleID string

id of the current loale

Source:
Returns:
  • array of Objects representing available locales
Type
Array

getLoginRedirectURL(redirectUrl, privacyCache, newlyRegisteredUser) β†’ {string}

Creates an account model for the current customer

Parameters:
Name Type Description
redirectUrl string

rurl of the req.querystring

privacyCache string

req.session.privacyCache

newlyRegisteredUser boolean

req.session.privacyCache

Source:
Returns:

a redirect url

Type
string

getMatchingProducts(productId, productLineItems) β†’ {Object|Array.<dw.order.ProductLineItem>}

Find all line items that contain the product specified. A product can appear in different line items that have different option selections or in product bundles.

Parameters:
Name Type Description
productId string

Product ID to match

productLineItems dw.util.Collection.<dw.order.ProductLineItem>

Collection of the Cart's product line items

Source:
Returns:
  • properties includes, matchingProducts - collection of matching products uuid - string value for the last product line item

    Type
    Object
    • Filtered list of product line items matching productId
    Type
    Array.<dw.order.ProductLineItem>

getMinMaxQuantityOptions(productLineItem, quantity) β†’ {Object}

get the min and max numbers to display in the quantity drop down.

Parameters:
Name Type Description
productLineItem Object

a line item of the basket.

quantity number

number of items for this product

Source:
Returns:

The minOrderQuantity and maxOrderQuantity to display in the quantity drop down.

Type
Object

getNewBonusDiscountLineItem(currentBasket, previousBonusDiscountLineItems, urlObject, pliUUID) β†’ {Object}

Gets the newly added bonus discount line item

Parameters:
Name Type Description
currentBasket dw.order.Basket
previousBonusDiscountLineItems dw.util.Collection

contains BonusDiscountLineItems already processed

urlObject Object

Object with data to be used in the choice of bonus products modal

pliUUID string

the uuid of the qualifying product line item.

Source:
Returns:
  • either the object that represents data needed for the choice of bonus products modal window or undefined
Type
Object

getOptions(optionModel, attributeVariables) β†’ {Array.<ProductOptions>}

Retrieve provided product's options

Parameters:
Name Type Description
optionModel dw.catalog.ProductOptionModel

Product's option model

attributeVariables Object

Variation attribute query params

Source:
Returns:
  • Parsed options for this product
Type
Array.<ProductOptions>

getOptionValues(optionModel, option, optionValues, attributeVariables) β†’ {ProductOptionValues}

Get a product option's values

Parameters:
Name Type Description
optionModel dw.catalog.ProductOptionModel

A product's option model

option dw.catalog.ProductOption

A product's option

optionValues dw.util.Collection.<dw.catalog.ProductOptionValue>

Product option values

attributeVariables Object

Variation attribute query params

Source:
Returns:
  • View model for a product option's values
Type
ProductOptionValues

getOrderDetails(req) β†’ {Object}

Creates an order model for the current customer

Parameters:
Name Type Description
req Object

the request object

Source:
Returns:

an object of the customer's order

Type
Object

getOrderLevelDiscountTotal(lineItemContainer) β†’ {Object}

Gets the order discount amount by subtracting the basket's total including the discount from the basket's total excluding the order discount.

Parameters:
Name Type Description
lineItemContainer dw.order.LineItemCtnr

Current users's basket

Source:
Returns:

an object that contains the value and formatted value of the order discount

Type
Object

getOrderPlacedReportingURLs(orderCount, reportingURLs) β†’ {Array}

Build the urls that report on order placed by a customer

Parameters:
Name Type Description
orderCount number

The number of orders this customer placed in the system

reportingURLs Array

current array of reporting urls

Source:
Returns:
  • an array of urls that are used to report
Type
Array

getOrderPromoReportingURLs(priceAdjustments, reportingURLs) β†’ {Array}

get order promo reporting urls

Parameters:
Name Type Description
priceAdjustments dw.util.Collection

the price adjustments for the line item container

reportingURLs Array

current array of reporting urls

Source:
Returns:
  • an array of urls
Type
Array

getOrderReportingURLs(order) β†’ {Array}

Build the urls that report on the order

Parameters:
Name Type Description
order dw.order.Order

the order object

Source:
Returns:
  • an array of urls that are used to report on the current order
Type
Array

getOrders(currentCustomer, querystring, locale) β†’ {Object}

Returns a list of orders for the current customer

Parameters:
Name Type Description
currentCustomer Object

object with customer properties

querystring Object

querystring properties

locale string

the current request's locale id

Source:
Returns:
  • orderModel of the current dw order object
Type
Object

getPageDesignerCategoryPage(categoryID) β†’ {Object}

Retrieves the Category Landing Page, if available in Page Designer

Parameters:
Name Type Description
categoryID Object

the category ID as determined from the request

Source:
Returns:

a lookup result with these fields:

  • page - the page that is configured for this category, if any
  • invisiblePage - the page that is configured for this category if we ignore visibility, if it is different from page
  • aspectAttributes - the aspect attributes that should be passed to the PageMgr, null if no page was found
Type
Object

getPageDesignerProductPage(reqProduct) β†’ {Object}

Retrieves the Product Detail Page, if available in Page Designer

Parameters:
Name Type Description
reqProduct Object

the product as determined from the request

Source:
Returns:

a lookup result with these fields:

  • page - the page that is configured for this product, if any
  • invisiblePage - the page that is configured for this product if we ignore visibility, if it is different from page
  • aspectAttributes - the aspect attributes that should be passed to the PageMgr, null if no page was found
Type
Object

getPageMetaData(pageMetaData) β†’ {Object}

Get a local instance of the pageMetaData object

Parameters:
Name Type Description
pageMetaData Object

Global request pageMetaData object

Source:
Returns:

object containing pageMetaData information

Type
Object

getPageMetadata(req) β†’ {Object}

Parameters:
Name Type Description
req Object

Request object

Source:
Returns:

object containing the querystring of the loaded page

Type
Object

getPagingModel(contentHits, count, pageSize, startIndex) β†’ {dw.web.PagingModel}

Configures and returns a PagingModel instance

Parameters:
Name Type Description
contentHits dw.util.Iterator

Iterator for content search results

count number

Number of contents in search results

pageSize number

Number of contents to display

startIndex number

Beginning index value

Source:
Returns:
  • PagingModel instance
Type
dw.web.PagingModel

getPagingModel(productHits, count, pageSize, startIndex) β†’ {dw.web.PagingModel}

Configures and returns a PagingModel instance

Parameters:
Name Type Description
productHits dw.util.Iterator

Iterator for product search results

count number

Number of products in search results

pageSize number

Number of products to display

startIndex number

Beginning index value

Source:
Returns:
  • PagingModel instance
Type
dw.web.PagingModel

getPasswordResetToken(customer) β†’ {string}

Gets the password reset token of a customer

Parameters:
Name Type Description
customer Object

the customer requesting password reset token

Source:
Returns:

password reset token string

Type
string

getPayment(wallet) β†’ {Object}

Creates a plain object that contains payment instrument information

Parameters:
Name Type Description
wallet Object

current customer's wallet

Source:
Returns:

object that contains info about the current customer's payment instrument

Type
Object

getPaymentInstruments(rawPaymentInstruments) β†’ {Array}

Creates a list of payment instruments for the current user

Parameters:
Name Type Description
rawPaymentInstruments Array

current customer's payment instruments

Source:
Returns:

an array of payment instruments

Type
Array

Forms a URL that can be used as a permalink with filters, sort, and page size preserved

Parameters:
Name Type Description
productSearch dw.catalog.ProductSearchModel

Product search object

pageSize number

'sz' query param

startIdx number

'start' query param

Source:
Returns:
  • Permalink URL
Type
string

getPhrases(suggestedPhrases) β†’ {Array.<SuggestedPhrase>}

Compile a list of relevant suggested phrases

Parameters:
Name Type Description
suggestedPhrases dw.util.Iterator.<dw.suggest.SuggestedPhrase>

Iterator to retrieve suggestedPhrases

Source:
Returns:
  • Array of suggested phrases
Type
Array.<SuggestedPhrase>

getPhrases(suggestedPhrases, maxItems) β†’ {Array.<SuggestedPhrase>}

Compile a list of relevant suggested phrases

Parameters:
Name Type Description
suggestedPhrases dw.util.Iterator.<dw.suggest.SuggestedPhrase>

Iterator to retrieve SuggestedPhrases

maxItems number

Maximum number of phrases to retrieve

Source:
Returns:
  • Array of suggested phrases
Type
Array.<SuggestedPhrase>

getPhrases(suggestedPhrases, maxItems) β†’ {Array.<SuggestedPhrase>}

Compile a list of relevant suggested phrases

Parameters:
Name Type Description
suggestedPhrases dw.util.Iterator.<dw.suggest.SuggestedPhrase>

Iterator to retrieve SuggestedPhrases

maxItems number

Maximum number of phrases to retrieve

Source:
Returns:
  • Array of suggested phrases
Type
Array.<SuggestedPhrase>

getPreferredAddress(addressBook) β†’ {Object}

Creates a plain object that contains the customer's preferred address

Parameters:
Name Type Description
addressBook Object

target customer

Source:
Returns:

an object that contains information about current customer's preferred address

Type
Object

getPrice(inputProduct, currency, useSimplePrice, promotions, currentOptionModel) β†’ {TieredPrice|RangePrice|DefaultPrice}

Retrieves Price instance

Parameters:
Name Type Description
inputProduct dw.catalog.Product | dw.catalog.productSearchHit

API object for a product

currency string

Current session currencyCode

useSimplePrice boolean

Flag as to whether a simple price should be used, used for product tiles and cart line items.

promotions dw.util.Collection.<dw.campaign.Promotion>

Promotions that apply to this product

currentOptionModel dw.catalog.ProductOptionModel

The product's option model

Source:
Returns:
  • The product's price
Type
TieredPrice | RangePrice | DefaultPrice

getProductLineItem(currentBasket, pliUUID) β†’ {dw.order.ProductLineItem}

Finds and returns a ProductLineItem by UUID

Parameters:
Name Type Description
currentBasket dw.order.Basket

the basket to search

pliUUID string

the target UUID

Source:
Returns:

the associated ProductLineItem

Type
dw.order.ProductLineItem

getProductLineItemsModel(shipment, containerView) β†’ {ProductLineItemsModel}

Plain JS object that represents a DW Script API dw.order.ShippingMethod object

Parameters:
Name Type Description
shipment dw.order.Shipment

the target Shipment

containerView string

the view of the product line items (order or basket)

Source:
Returns:

an array of ShippingModels

Type
ProductLineItemsModel

getProducts(suggestedProducts, maxItems) β†’ {Array.<Object>}

Compile a list of relevant suggested products

Parameters:
Name Type Description
suggestedProducts dw.util.Iterator.<dw.suggest.SuggestedProduct>

Iterator to retrieve SuggestedProducts

maxItems number

Maximum number of products to retrieve

Source:
Returns:
  • Array of suggested products
Type
Array.<Object>

getProductSchema(product) β†’ {Object}

Get product schema information

Parameters:
Name Type Description
product Object

Product Object

Source:
Returns:
  • Product Schema object
Type
Object

getProductSearchHit(apiProduct) β†’ {dw.catalog.ProductSearchHit}

Get product search hit for a given product

Parameters:
Name Type Description
apiProduct dw.catalog.Product

Product instance returned from the API

Source:
Returns:
  • product search hit for a given product
Type
dw.catalog.ProductSearchHit

getProductSearchReportingURLs(productSearch) β†’ {Array}

Build the urls that report on the product search

Parameters:
Name Type Description
productSearch Object

product search model

Source:
Returns:
  • an array of urls that are used to report
Type
Array

getProductType(product) β†’ {string}

Return type of the current product

Parameters:
Name Type Description
product dw.catalog.ProductVariationModel

Current product

Source:
Returns:

type of the current product

Type
string

getProfile(profile) β†’ {Object}

Creates a plain object that contains profile information

Parameters:
Name Type Description
profile Object

current customer's profile

Source:
Returns:

an object that contains information about the current customer's profile

Type
Object

getPromotionPrice(product, promotions, currentOptionModel) β†’ {dw.value.Money}

Get a product's promotional price

Parameters:
Name Type Description
product dw.catalog.Product

Product under evaluation

promotions dw.util.Collection.<dw.campaign.Promotion>

Promotions that apply to this product

currentOptionModel dw.catalog.ProductOptionModel

The product's option model

Source:
Returns:
  • Promotional price
Type
dw.value.Money

getPromotions(searchHit, activePromotions) β†’ {Array.<Promotion>}

Retrieve promotions that apply to current product

Parameters:
Name Type Description
searchHit dw.catalog.ProductSearchHit

current product returned by Search API.

activePromotions Array.<string>

array of ids of currently active promotions

Source:
Returns:
  • Array of promotions for current product
Type
Array.<Promotion>

getQtyAlreadyInCart(productId, lineItems, uuidopt) β†’ {number}

Calculate the quantities for any existing instance of a product, either as a single line item with the same or different options, as well as inclusion in product bundles. Providing an optional "uuid" parameter, typically when updating the quantity in the Cart, will exclude the quantity for the matching line item, as the updated quantity will be used instead. "uuid" is not used when adding a product to the Cart.

Parameters:
Name Type Attributes Description
productId string

ID of product to be added or updated

lineItems dw.util.Collection.<dw.order.ProductLineItem>

Cart product line items

uuid string <optional>

When provided, excludes the quantity for the matching line item

Source:
Returns:
  • Total quantity of all instances of requested product in the Cart and being requested
Type
number

getQuantities(minOrderQty, maxOrderQty, stepQuantity, selectedQty, pid, attributes, options) β†’ {Array}

Compile quantity meta for pull-down menu selection

Parameters:
Name Type Description
minOrderQty number

Minimum order quantity

maxOrderQty number

Maximum order quantity

stepQuantity number

Quantity increment from one value to the next

selectedQty string

Quanity selected

pid string

Product ID

attributes Object

Variation attribute query params

options Array.<ProductOptions>

Product options query params

Source:
Returns:
  • Quantity options for PDP pull-down menu
Type
Array

getRefinements(productSearch, refinements, refinementDefinitions) β†’ {Array.<Refinement>}

Retrieves search refinements

Parameters:
Name Type Description
productSearch dw.catalog.ProductSearchModel

Product search object

refinements dw.catalog.ProductSearchRefinements

Search refinements

refinementDefinitions ArrayList.<dw.catalog.ProductSearchRefinementDefinition>

List of product serach refinement definitions

Source:
Returns:
  • List of parsed refinements
Type
Array.<Refinement>

getRenderedHtml(templateContext, templateName) β†’ {string}

gets the render html for the given isml template

Parameters:
Name Type Description
templateContext Object

object that will fill template placeholders

templateName string

the name of the isml template to render.

Source:
Returns:

the rendered isml.

Type
string

getRenderedPaymentInstruments(req, accountModel) β†’ {string|null}

renders the user's stored payment Instruments

Parameters:
Name Type Description
req Object

The request object

accountModel Object

The account model for the current customer

Source:
Returns:

newly stored payment Instrument

Type
string | null

getRenderedPrice(price) β†’ {string}

Renders pricing template for line item

Parameters:
Name Type Description
price Object

Factory price

Source:
Returns:
  • Rendered HTML
Type
string

getRenderedPromotions(appliedPromotions) β†’ {string}

get the rendered applied promotions

Parameters:
Name Type Description
appliedPromotions Array.<Object>

an array of objects containing the product line items applied promotions

Source:
Returns:

the rendered html for the applied promotions

Type
string

getReportingUrlAddToCart(currentBasket, resultError) β†’ {string|boolean}

return a link to enable reporting of add to cart events

Parameters:
Name Type Description
currentBasket dw.order.Basket

the target Basket object

resultError boolean

the target Basket object

Source:
Returns:

returns a url or boolean value false

Type
string | boolean

getRequestBodyAsString(request) β†’ {string|Null}

Get request body as string if it is a POST or PUT

Parameters:
Name Type Description
request Object

Global request object

Source:
Returns:

the request body as string

Type
string | Null

Generates URL that removes refinements, essentially resetting search criteria

Parameters:
Name Type Description
search dw.catalog.ProductSearchModel

Product search object

httpParams Object

Query params

Properties
Name Type Attributes Description
q string <optional>

Search keywords

cgid string <optional>

Category ID

Source:
Returns:
  • URL to reset query to original search
Type
string

getResources() β†’ {ProductDetailPageResourceMap}

Generates a map of string resources for the template

Source:
Returns:
  • String resource map
Type
ProductDetailPageResourceMap

getRootPriceBook(priceBook) β†’ {dw.catalog.PriceBook}

Return root price book for a given price book

Parameters:
Name Type Description
priceBook dw.catalog.PriceBook

Provided price book

Source:
Returns:

root price book

Type
dw.catalog.PriceBook

getSelectedFilters(refinements) β†’ {Array.<Object>}

Returns the refinement values that have been selected

Parameters:
Name Type Description
refinements Array.<(CategoryRefinementValue|AttributeRefinementValue|PriceRefinementValue)>

List of all relevant refinements for this search

Source:
Returns:
  • List of selected filters
Type
Array.<Object>

getSelectedOptionsUrl(optionModel, actionopt) β†’ {string}

Generates a URL with the currently selected product options

Parameters:
Name Type Attributes Description
optionModel dw.catalog.ProductOptionModel

The product's option model

action string <optional>

URL endpoint

Source:
Returns:
  • URL with option query params
Type
string

getSelectedPaymentInstruments(selectedPaymentInstruments) β†’ {Array}

Creates an array of objects containing selected payment information

Parameters:
Name Type Description
selectedPaymentInstruments dw.util.ArrayList.<dw.order.PaymentInstrument>

ArrayList of payment instruments that the user is using to pay for the current basket

Source:
Returns:

Array of objects that contain information about the selected payment instruments

Type
Array

getSelectedShippingMethod(shipment) β†’ {Object}

Plain JS object that represents a DW Script API dw.order.ShippingMethod object

Parameters:
Name Type Description
shipment dw.order.Shipment

the target Shipment

Source:
Returns:

a ShippingMethodModel object

Type
Object

getSessionObject(session) β†’ {Object}

Translates global session object into local object

Parameters:
Name Type Description
session dw.session

Global customer object

Source:
Returns:

local instance of session object

Type
Object

getSetProductsLength(apiProduct) β†’ {int}

Parameters:
Name Type Description
apiProduct dw.catalog.Product

Product returned by the API

Source:
Returns:

the number of the products in the Set

Type
int

getShipmentByUUID(basket, uuid) β†’ {dw.order.Shipment}

Plain JS object that represents a DW Script API dw.order.ShippingMethod object

Parameters:
Name Type Description
basket dw.order.Basket

the target Basket

uuid string

the matching UUID to match against Shipments

Source:
Returns:

a Shipment object

Type
dw.order.Shipment

getShipmentUUID(shipment) β†’ {string}

ppingMethod object

Parameters:
Name Type Description
shipment dw.order.Shipment

the target Shipment

Source:
Returns:

the Shipment UUID or null

Type
string

getShippingCost(shippingMethod, shipment) β†’ {string}

Returns shippingCost property for a specific Shipment / ShippingMethod pair

Parameters:
Name Type Description
shippingMethod dw.order.ShippingMethod

the default shipment of the current basket

shipment dw.order.Shipment

a shipment of the current basket

Source:
Returns:

String representation of Shipping Cost

Type
string

getShippingLevelDiscountTotal(lineItemContainer) β†’ {Object}

Gets the shipping discount total by subtracting the adjusted shipping total from the shipping total price

Parameters:
Name Type Description
lineItemContainer dw.order.LineItemCtnr

Current users's basket

Source:
Returns:

an object that contains the value and formatted value of the shipping discount

Type
Object

getShippingModels(currentBasket, customer, containerView) β†’ {dw.util.ArrayList}

Plain JS object that represents a DW Script API dw.order.ShippingMethod object

Parameters:
Name Type Description
currentBasket dw.order.Basket

the target Basket object

customer Object

the associated Customer Model object

containerView string

view of the shipping models (order or basket)

Source:
Returns:

an array of ShippingModels

Type
dw.util.ArrayList

getShippingPromoReportingURLs(shipment, reportingURLs) β†’ {Array}

get shipping promo reporting urls

Parameters:
Name Type Description
shipment dw.order.Shipment

the target shipment

reportingURLs Array

current array of reporting urls

Source:
Returns:
  • an array of urls
Type
Array

getShowMoreUrl(productSearch, httpParams) β†’ {string}

Generates URL for [Show] More button

Parameters:
Name Type Description
productSearch dw.catalog.ProductSearchModel

Product search object

httpParams Object

HTTP query parameters

Source:
Returns:
  • More button URL
Type
string

getSortingOptions(productSearch, sortingOptions, pagingModel) β†’ {SortingOption}

Retrieves sorting options

Parameters:
Name Type Description
productSearch dw.catalog.ProductSearchModel

Product search instance

sortingOptions dw.util.List.<dw.catalog.SortingOption>

List of sorting rule options

pagingModel dw.web.PagingModel

The paging model for the current search context

Source:
Returns:
  • Sorting option
Type
SortingOption

getSortRuleDefault(productSearch, rootCategory) β†’ {string}

Retrieves refined or default category sort ID

Parameters:
Name Type Description
productSearch dw.catalog.ProductSearchModel

Product search instance

rootCategory dw.catalog.Category

Catalog's root category

Source:
Returns:
  • Sort rule ID or null if no default sorting rule specified
Type
string

getStores(radius, postalCode, lat, long, geolocation, showMap, url) β†’ {Object}

Searches for stores and creates a plain object of the stores returned by the search

Parameters:
Name Type Description
radius string

selected radius

postalCode string

postal code for search

lat string

latitude for search by latitude

long string

longitude for search by longitude

geolocation Object

geloaction object with latitude and longitude

showMap boolean

boolean to show map

url dw.web.URL

a relative url

Source:
Returns:

a plain object containing the results of the search

Type
Object

getTotalPrice(lineItem) β†’ {Object}

get the total price for the product line item

Parameters:
Name Type Description
lineItem dw.order.ProductLineItem

API ProductLineItem instance

Source:
Returns:

an object containing the product line item total info.

Type
Object

getTotalQuantity(items) β†’ {number}

Loops through all of the product line items and adds the quantities together.

Parameters:
Name Type Description
items dw.util.Collection.<dw.order.ProductLineItem>

All product line items of the basket

Source:
Returns:

a number representing all product line items in the lineItem container.

Type
number

getTotals(total) β†’ {string}

Accepts a total object and formats the value

Parameters:
Name Type Description
total dw.value.Money

Total price of the cart

Source:
Returns:

the formatted money value

Type
string

getUrl(variationModel, optionModel, endPoint, id, quantity) β†’ {string}

creates a url of the product's selected attributes

Parameters:
Name Type Description
variationModel dw.catalog.ProductVariationModel

The product's variation model

optionModel dw.catalog.ProductOptionModel

The product's option model

endPoint string

the endpoint to use when generating urls for product attributes

id string

the current product's id

quantity number

quantity to purchase

Source:
Returns:

a url of the product's selected attributes

Type
string

getVariationModel(product, productVariables) β†’ {dw.catalog.ProductVarationModel}

Normalize product and return Product variation model

Parameters:
Name Type Description
product dw.catalog.Product

Product instance returned from the API

productVariables Object

variables passed in the query string to target product variation group

Source:
Returns:

Normalized variation model

Type
dw.catalog.ProductVarationModel

Handle(basket, paymentInformation, paymentMethodID, req) β†’ {Object}

Verifies that entered credit card information is a valid card. If the information is valid a credit card payment instrument is created

Parameters:
Name Type Description
basket dw.order.Basket

Current users's basket

paymentInformation Object

the payment information

paymentMethodID string

paymentmethodID

req Object

the request object

Source:
Returns:

returns an error object

Type
Object

Handle() β†’ {Object}

default hook if no payment processor is supported

Source:
Returns:

an object that contains error information

Type
Object

handlePayments(order, orderNumber) β†’ {Object}

handles the payment authorization for each payment instrument

Parameters:
Name Type Description
order dw.order.Order

the order object

orderNumber string

The order number for the order

Source:
Returns:

an error object

Type
Object

hasSameOptions(existingOptions, selectedOptions) β†’ {boolean}

Determines whether a product's current options are the same as those just selected

Parameters:
Name Type Description
existingOptions dw.util.Collection

Options currently associated with this product

selectedOptions Array.<SelectedOption>

Product options just selected

Source:
Returns:
  • Whether a product's current options are the same as those just selected
Type
boolean

http(req, res, next) β†’ {void}

Middleware filter for http requests

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

next function

Next call in the middleware chain

Source:
Returns:
Type
void

https(req, res, next) β†’ {void}

Middleware filter for https requests

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

next function

Next call in the middleware chain

Source:
Returns:
Type
void

include(req, res, next) β†’ {void}

Middleware to filter for remote includes

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

next function

Next call in the middleware chain

Source:
Returns:
Type
void

init(model, context) β†’ {Object}

Helper to encapsulate common code for building a carousel

Parameters:
Name Type Description
model Object

model object for a component

context Object

model object for a component

Source:
Returns:

model - prepared model

Type
Object

isLocaleValid(currentLocale) β†’ {boolean}

Performs a deeper check on a plain locale object

Parameters:
Name Type Description
currentLocale dw.util.Locale

current locale of the request

Source:
Returns:
  • returns true
Type
boolean

isShippingAddressInitialized(shipmentopt) β†’ {boolean}

Checks to see if the shipping address is initialized

Parameters:
Name Type Attributes Description
shipment dw.order.Shipment <optional>

Script API Shipment object

Source:
Returns:

returns true if defaulShipment.shippingAddress is not null

Type
boolean

isSwatchable(dwAttributeId) β†’ {boolean}

Determines whether a product attribute has image swatches. Currently, the only attribute that does is Color.

Parameters:
Name Type Description
dwAttributeId string

Id of the attribute to check

Source:
Returns:

flag that specifies if the current attribute should be displayed as a swatch

Type
boolean

json(data, response) β†’ {void}

Render JSON as an output

Parameters:
Name Type Description
data Object

Object to be turned into JSON

response Object

Response object

Source:
Returns:
Type
void

map(collection, callback, scopeopt) β†’ {Array}

Map method for dw.util.Collection subclass instance

Parameters:
Name Type Attributes Description
collection dw.util.Collection

Collection subclass instance to map over

callback function

Callback function for each item

scope Object <optional>

Optional execution scope to pass to callback

Source:
Returns:

Array of results of map

Type
Array

normalizeSelectedAttributes(apiProduct, params) β†’ {Object}

If a product is master and only have one variant for a given attribute - auto select it

Parameters:
Name Type Description
apiProduct dw.catalog.Product

Product from the API

params Object

Parameters passed by querystring

Source:
Returns:
  • Object with selected parameters
Type
Object

page(pageID, aspectAttributes, data, response) β†’ {void}

Render a page designer page

Parameters:
Name Type Description
pageID string

Path to an ISML template

aspectAttributes dw.util.HashMap

aspectAttributes to be passed to the PageMgr

data Object

Data to be passed

response Object

Response object

Source:
Returns:
Type
void

parameterToArray(object, key, value) β†’ {Object}

Detect duplicate parameters and be sure to set object[key] as an array of those parameter values

Parameters:
Name Type Description
object Object

The object to check for existing values.

key string

The key to set on object for the new value.

value string

The new value to be added to object[key].

Source:
Returns:

Value or array of values if object[key] has already exists.

Type
Object

parseForm(form) β†’ {Object}

Convert dw.web.Form or dw.web.FormGroup to plain JS object

Parameters:
Name Type Description
form dw.web.Form | dw.web.FormGroup

Form to be parsed

Source:
Returns:

Plain JS form object

Type
Object

parsePreferences(preferences) β†’ {Object}

Zips the pref[n|v] http query params

The Platform allows the use of multiple preference names and values to filter search results, eg.: http://.com/../Search-Show?prefn1=refinementColor&prefv1=Blue&prefn2=size&prefv2=16

Parameters:
Name Type Description
preferences Object

HTTP query parameters map specific to selected refinement values

Source:
Returns:

Map of provided preference name/value pairs

Type
Object

placeOrder(order, fraudDetectionStatus) β†’ {Object}

Attempts to place the order

Parameters:
Name Type Description
order dw.order.Order

The order object to be placed

fraudDetectionStatus Object

an Object returned by the fraud detection hook

Source:
Returns:

an error object

Type
Object

pluck(list, property) β†’ {Array}

Pluck method for dw.util.Collection subclass instance

Parameters:
Name Type Description
list dw.util.Collection | dw.util.Iterator

Collection subclass or Iterator instance to pluck from

property string

Object property to pluck

Source:
Returns:

Array of results of plucked properties

Type
Array

post(req, res, next) β†’ {void}

Middleware filter for post requests

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

next function

Next call in the middleware chain

Source:
Returns:
Type
void

postAuthorization(result)

This function is to handle the post payment authorization customizations

Parameters:
Name Type Description
result Object

Authorization Result

Source:

prepareBillingForm() β†’ {Object}

Prepares the Billing form

Source:
Returns:

processed Billing form object

Type
Object

prepareShippingForm() β†’ {Object}

Prepares the Shipping form

Source:
Returns:

processed Shipping form object

Type
Object

processForm(req, paymentForm, viewFormData) β†’ {Object}

Verifies the required information for billing form is provided.

Parameters:
Name Type Description
req Object

The request object

paymentForm Object

the payment form

viewFormData Object

object contains billing form data

Source:
Returns:

an object that has error information or payment information

Type
Object

processForm() β†’ {Object}

default hook if no payment form processor is supported

Source:
Returns:

an object that contains error information

Type
Object

recalculateBasket(currentBasket)

Recalculates the currentBasket

Parameters:
Name Type Description
currentBasket dw.order.Basket

the target Basket

Source:

reduce(collection, callback) β†’ {Object}

reduce method for dw.util.Collection subclass instances

Parameters:
Name Type Description
collection dw.util.Collection

Collection subclass instance to reduce

callback function

Function to execute on each value in the array

Source:
Returns:

result of the execution of callback function on all items

Type
Object

removeFormValues(form) β†’ {void}

Removes the htmlValue and value properties of a form

Parameters:
Name Type Description
form Object

the target product line item

Source:
Returns:
Type
void

renderHtml(context, templatePathopt) β†’ {string}

Render Template HTML

Parameters:
Name Type Attributes Description
context dw.util.HashMap

Context object that will fill template placeholders

templatePath string <optional>

Optional template path to override default

Source:
Returns:
  • Rendered HTML
Type
string

renderSkin() β†’ {string}

This function is called within the html head and renders its output there. It gathers either a css file from a content asset for external skin.css or the body element inline for quicker critical css introduction

Source:
Returns:

text to be rendered

Type
string

saveAddress(address, customer, addressId) β†’ {void}

Stores a new address for a given customer

Parameters:
Name Type Description
address Object

New address to be saved

customer Object

Current customer

addressId string

Id of a new address to be created

Source:
Returns:
Type
void

savePaymentInformation(req, basket, billingData)

Save the credit card information to login account if save card option is selected

Parameters:
Name Type Description
req Object

The request object

basket dw.order.Basket

The current basket

billingData Object

payment information

Source:

savePaymentInformation()

default hook if no save payment information processor is supported

Source:

savePaymentInstrumentToWallet(billingData, currentBasket, customer) β†’ {dw.customer.CustomerPaymentInstrument}

saves payment instruemnt to customers wallet

Parameters:
Name Type Description
billingData Object

billing information entered by the user

currentBasket dw.order.Basket

The current basket

customer dw.customer.Customer

The current customer

Source:
Returns:

newly stored payment Instrument

Type
dw.customer.CustomerPaymentInstrument

performs a search

Parameters:
Name Type Description
req Object

Provided HTTP query parameters

res Object

Provided HTTP query parameters

httpParameterMap Object

Query params

Source:
Returns:
  • an object with relevant search information
Type
Object

selectShippingMethod(shipment, shippingMethodID, shippingMethods, address)

Sets the shipping method of the basket's default shipment

Parameters:
Name Type Description
shipment dw.order.Shipment

Any shipment for the current basket

shippingMethodID string

The shipping method ID of the desired shipping method

shippingMethods dw.util.Collection

List of applicable shipping methods

address Object

the address

Source:

send(emailObj, template, context)

Helper that sends an email to a customer. This will only get called if hook handler is not registered

Parameters:
Name Type Description
emailObj obj

An object that contains information about email that will be sent

Properties
Name Type Description
to string

Email address to send the message to (required)

subject string

Subject of the message to be sent (required)

from string

Email address to be used as a "from" address in the email (required)

type int

Integer that specifies the type of the email being sent out. See export from emailHelpers for values.

template string

Location of the ISML template to be rendered in the email.

context obj

Object with context to be passed as pdict into ISML template.

Source:

sendAccountEditedEmail(profile)

Send an email that would notify the user that account was edited

Parameters:
Name Type Description
profile obj

object that contains user's profile information.

Source:

sendConfirmationEmail(order, locale) β†’ {void}

Sends a confirmation to the current user

Parameters:
Name Type Description
order dw.order.Order

The current user's order

locale string

the current request's locale id

Source:
Returns:
Type
void

sendCreateAccountEmail(registeredUser)

Send an email that would notify the user that account was created

Parameters:
Name Type Description
registeredUser obj

object that contains user's email address and name information.

Source:

sendPasswordResetEmail(email, resettingCustomer)

Sends the email with password reset instructions

Parameters:
Name Type Description
email string

email for password reset

resettingCustomer Object

the customer requesting password reset

Source:

setCurrency(request, session)

set currency of the current locale if there's a mismatch

Parameters:
Name Type Description
request Object

Global request object

session dw.system.Session

Global session object

Source:

setGift(shipment, isGift, giftMessage) β†’ {Object}

sets the gift message on a shipment

Parameters:
Name Type Description
shipment dw.order.Shipment

Any shipment for the current basket

isGift boolean

is the shipment a gift

giftMessage string

The gift message the user wants to attach to the shipment

Source:
Returns:

object containing error information

Type
Object

setPageMetaData(pageMetaData, object)

Set page meta Data including page title, page description and page keywords

Parameters:
Name Type Description
pageMetaData Object

Global request pageMetaData object

object Object

object which contains page meta data for instance product/content

Source:

setPageMetaTags(pageMetaData, object)

Set page meta tags to support rule based meta data

Parameters:
Name Type Description
pageMetaData Object

Global request pageMetaData object

object Object

object which contains page meta tags

Source:

setProductProperties(productSearch, httpParams, selectedCategory, sortingRule, httpParameterMap)

Sets the relevant product search model properties, depending on the parameters provided

Parameters:
Name Type Description
productSearch dw.catalog.ProductSearchModel

Product search object

httpParams Object

Query params

selectedCategory dw.catalog.Category

Selected category

sortingRule dw.catalog.SortingRule

Product grid sort rule

httpParameterMap Object

Query params

Properties:
Name Type Attributes Description
httpParameterMap.pmin Double <optional>

Minimum Price

httpParameterMap.pmax Double <optional>

Maximum Price

Source:

setupContentSearch(params) β†’ {Object}

Set content search configuration values

Parameters:
Name Type Description
params Object

Provided HTTP query parameters

Source:
Returns:
  • content search instance
Type
Object

setupSearch(apiProductSearch, params, httpParameterMap) β†’ {dw.catalog.ProductSearchModel}

Set search configuration values

Parameters:
Name Type Description
apiProductSearch dw.catalog.ProductSearchModel

API search instance

params Object

Provided HTTP query parameters

httpParameterMap Object

Query params

Source:
Returns:
  • API search instance
Type
dw.catalog.ProductSearchModel

ShippingMethodModel(shippingMethod, shipmentopt)

Plain JS object that represents a DW Script API dw.order.ShippingMethod object

Parameters:
Name Type Attributes Description
shippingMethod dw.order.ShippingMethod

the default shipment of the current basket

shipment dw.order.Shipment <optional>

a Shipment

Source:

showProductPage(querystring, reqPageMetaData, usePageDesignerTemplates) β†’ {Object}

Renders the Product Details Page

Parameters:
Name Type Description
querystring Object

query string parameters

reqPageMetaData Object

request pageMetaData object

usePageDesignerTemplates Object

wether to use the page designer version of the product detail templates, defaults to false

Source:
Returns:

contain information needed to render the product page

Type
Object

SimpleCache(storeopt)

Represents a simple key/value store

Parameters:
Name Type Attributes Description
store Object <optional>

a bracket notation-compatible object

Source:

template(view, viewData, response) β†’ {void}

Render an ISML template

Parameters:
Name Type Description
view string

Path to an ISML template

viewData Object

Data to be passed as pdict

response Object

Response object

Source:
Returns:
Type
void

toPriceModel(price) β†’ {Object}

Convert API price to an object

Parameters:
Name Type Description
price dw.value.Money

Price object returned from the API

Source:
Returns:

price formatted as a simple object

Type
Object

updateAddressFields(newAddress, address)

Copy information from address object and save it in the system

Parameters:
Name Type Description
newAddress dw.customer.CustomerAddress

newAddress to save information into

address *

Address to copy from

Source:

updateBundleProducts(apiLineItem, childProducts)

Replaces Bundle master product items with their selected variants

Parameters:
Name Type Description
apiLineItem dw.order.ProductLineItem

Cart line item containing Bundle

childProducts Array.<string>

List of bundle product item ID's with chosen product variant ID's

Source:

validateAjaxRequest(req, res, next) β†’ {void}

Middleware validating CSRF token from ajax request

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

next function

Next call in the middleware chain

Source:
Returns:
Type
void

validateBasket(basket, validateTax) β†’ {Object}

validates the current users basket

Parameters:
Name Type Description
basket dw.order.Basket

The current user's basket

validateTax boolean

boolean that determines whether or not to validate taxes

Source:
Returns:

an error object

Type
Object

validateBillingForm(form, fields) β†’ {Object}

Validate billing form fields

Parameters:
Name Type Description
form Object

the form object with pre-validated form fields

fields Array

the fields to validate

Source:
Returns:

the names of the invalid form fields

Type
Object

validateCoupons(basket) β†’ {Object}

Validates coupons

Parameters:
Name Type Description
basket dw.order.Basket

The current user's basket

Source:
Returns:

an error object

Type
Object

validateCreditCard(form) β†’ {Object}

Validate credit card form fields

Parameters:
Name Type Description
form Object

the form object with pre-validated form fields

Source:
Returns:

the names of the invalid form fields

Type
Object

validateEmail(email) β†’ {boolean}

Checks if the email value entered is correct format

Parameters:
Name Type Description
email string

email string to check if valid

Source:
Returns:

Whether email is valid

Type
boolean

validateEmail(email) β†’ {boolean}

Checks if the email value entered is correct format

Parameters:
Name Type Description
email string

email string to check if valid

Source:
Returns:

Whether email is valid

Type
boolean

validateEmail(email) β†’ {boolean}

Checks if the email value entered is correct format

Parameters:
Name Type Description
email string

email string to check if valid

Source:
Returns:

Whether email is valid

Type
boolean

validateFields(form) β†’ {Object}

Validate billing form

Parameters:
Name Type Description
form Object

the form object with pre-validated form fields

Source:
Returns:

the names of the invalid form fields

Type
Object

validateLoggedIn(req, res, next) β†’ {void}

Middleware validating if user logged in

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

next function

Next call in the middleware chain

Source:
Returns:
Type
void

validateLoggedInAjax(req, res, next) β†’ {void}

Middleware validating if user logged in from ajax request

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

next function

Next call in the middleware chain

Source:
Returns:
Type
void

validateOrder(basket, validateTax) β†’ {Object}

validates the current users basket

Parameters:
Name Type Description
basket dw.order.Basket

The current user's basket

validateTax boolean

boolean that determines whether or not to validate taxes

Source:
Returns:

an error object

Type
Object

validatePayment(req, currentBasket) β†’ {Object}

Validates payment

Parameters:
Name Type Description
req Object

The local instance of the request object

currentBasket dw.order.Basket

The current basket

Source:
Returns:

an object that has error information

Type
Object

validateProducts(basket) β†’ {Object}

validates that the product line items exist, are online, and have available inventory.

Parameters:
Name Type Description
basket dw.order.Basket

The current user's basket

Source:
Returns:

an error object

Type
Object

validateRequest(req, res, next) β†’ {void}

Middleware validating CSRF token

Parameters:
Name Type Description
req Object

Request object

res Object

Response object

next function

Next call in the middleware chain

Source:
Returns:
Type
void

validateShippingForm(form, fields) β†’ {Object}

Validate shipping form fields

Parameters:
Name Type Description
form Object

the form object with pre-validated form fields

fields Array

the fields to validate

Source:
Returns:

the names of the invalid form fields

Type
Object

verifyCard(req, card, form) β†’ {boolean}

Checks if a credit card is valid or not

Parameters:
Name Type Description
req Object

request object

card Object

plain object with card details

form Object

form object

Source:
Returns:

a boolean representing card validation

Type
boolean

xml(viewData, response) β†’ {void}

Render XML as an output

Parameters:
Name Type Description
viewData Object

Object to be turned into XML

response Object

Response object

Source:
Returns:
Type
void

Type Definitions

ProductDetailPageResourceMap

Type:
Properties:
Name Type Description
global_availability String

Localized string for "Availability"

label_instock String

Localized string for "In Stock"

global_availability String

Localized string for "This item is currently not available"

info_selectforstock String

Localized string for "Select Styles for Availability"

Source:

ProductOptions

Type:
Properties:
Name Type Description
id string

Product option ID

name string

Product option name

htmlName string

HTML representation of product option name

values ProductOptionValues

A product option's values

selectedValueId string

Selected option value ID

Source:

ProductOptionValues

Type:
Properties:
Name Type Description
id string

Product option value ID

displayValue string

Option value's display value

price string

Option values' price

Source:

Response

Type:
Properties:
Name Type Description
taxes Array.<TaxField>

List of taxes to line items UUIDs to be applied to the order

custom Object

List of custom properties to be attached to the basket

Source:

SelectedOption

Type:
Properties:
Name Type Description
optionId string

Option ID

selectedValueId string

Selected option value ID

Source:

SelectedOption

Type:
Properties:
Name Type Description
optionId string

Product option ID

productId string

Product ID

selectedValueId string

Selected product option value ID

Source:

SuggestedPhrase

Type:
Properties:
Name Type Description
exactMatch boolean

Whether suggested phrase is an exact match

value string

Suggested search phrase

Source:

TaxField

Type:
Properties:
Name Type Attributes Default Description
UUID string

ID of the line item

value number | dw.value.Money

Either Tax Code or Tax Amount that should be applied to the line item.

amount boolean <optional>
false

Boolean indicating whether value field contains Tax Amount (true) or Tax Rate (false).

Source:

urlObject

Type:
Properties:
Name Type Description
url string

Option ID

configureProductsUrl string

url that will be used to get selected bonus products

adToCartUrl string

url to use to add products to the cart

Source: