| Action Type | HTTP |
|---|---|
| Full Action ID | http.storefront.routes |
| Runs multiple custom functions? | Yes |
JavaScript File Structure
Action files share the following basic structure:callback—This argument follows the established JavaScript callback pattern: it takes an error as the first argument (or null if there is no error) and a result as the second argument (if required).
context—This argument provides the function access to relevant objects and methods that interface with Kibo eCommerce.
Context: HTTP
The following methods and objects are available to this action through the use of thecontext argument.
Storefront OperationThis action occurs during the storefront operation that obtains and renders view and model data from Hypr particular to the requested page. Context Objects Available to All HTTP Actions Context Methods Available to Storefront Actions Context Methods Available to All HTTP Actions
- request.get
- response.get
- response.set
- response.set
- response.remove
- response.redirect
- response.end
- get.resource
- get.resourceStatus
- items.urlHelper.getUrl
Context Objects Available to All HTTP Actions
request
Accesses the current HTTP request. In the case of Before actions, updates can be made to the request before Kibo eCommerce processes it.
*Available only for Storefront HTTP actions.
|
| query | object | The request query. |
| href | string | The request href. |
| secure | Boolean | Indicates whether the request uses HTTPS. |
| ip | string | The request IP address. |
| ips | string | The request secure IP address. |
| body | object | The request body of the API operation associated with this action. |
Example:
response
Accesses the current HTTP response. For both Before and After actions, updates can be made to the response before Kibo eCommerce processes it.
*Available only for Storefront HTTP actions.
|
| viewName | string |
The response viewName value.
*Available only for Storefront HTTP actions.
|
| body | object | The response body of the API operation associated with this action. |
| status | integer | The response status code. |
| message | string | The response message. |
| length | integer | The response length. |
| type | string | The response type. |
Example:
items.siteContext
Accesses the current site context.websiteName(string)—Name of the site as configured in the Admin general settings.timeZone(string)—The site time zone as configured in general settings in admin. Stored as human-readable string, e.g. “Mountain Standard Time”.allowInvalidAddresses(Boolean)—TRUE if address validation is enabled and invalid addresses are allowed, as configured in the Admin general settings.googleAnalyticsEcomEnabled(Boolean)—TRUE if Google Analytics is enabled and Google Analytics eCom tracking parameters are also enabled. In the Core theme and Core-derived themes, this results in a set of extra calls to the Google Analytics tracking beacon on the Order Confirmation page.googleAnalyticsEnabled(Boolean)—TRUE if Google Analytics is enabled. In the Core theme and Core-derived themes this results in a call to the Google Analytics tracking beacon on every page.googleAnalyticsId(string)—The UA number provided by the Google Analytics account as configured by the site.isAddressValidationEnabled(Boolean)—TRUE if address validation is enabled as configured in the Admin general settings.
payByMail(Boolean)—TRUE if pay-by-mail is enabled in the Admin checkout settings.isPayPalEnabled(Boolean)—TRUE if PayPal Express is enabled in Admin checkout settings.supportedCards(Dictionary<string, string>)—List of credit cards enabled in the Admin checkout settings.
theme.json. |
| isEditMode | Boolean | TRUE if the current site is being rendered inside an editor frame. Use this to display preview content in widgets or templates that would not work properly in an editing session. |
| cdnPrefix | string | The URL prefix for CDN content, composed of the host name plus a unique CDN identifier for the site. |
| secureHost | string | HTTPS version of the requested host name. |
| supportsInStorePickup | Boolean | TRUE if store pickup is enabled in the Admin location settings. |
| domains | siteDomains |
An object that lists the Current domain and the Primary domain, each of which has the following properties:
domainName(string)—the name of the domain.isPrimary(Boolean)—TRUE if the given domain is the primary one.
EnglishName(string)—the currency name.symbol(string)—the currency symbol.precision(integer)—the number of digits to display after the period.roundingType(string)—the rounding type value: “UpToCurrencyPrecision”, “NearestNickel”, “DownToNearestNickel”, “DownToCurrencyPrecisionMinusOne”, or “NearestHalfUnit”.currencyCode(string)—for example, “USD” for U.S. dollars. Other values include: “EGP”, “GBP”, “TZS”, “UYU”, “UZS”, “WST”, “YER”, “ZMK”, “TWD”, “GHS”, “VEF”, “SDG”, “RSD”, “MZN”, and “AZN”.
items.pageContext
Accesses the current page context.
|
| pageType | string | The
documentType of the current page, such as “web_page”, “cart”, “search”, etc. |
| isCrawler | Boolean | TRUE if the current page is requested by a search engine crawler. |
| isMobile | Boolean | TRUE if the current page is requested by a mobile device. |
| isTablet | Boolean | TRUE if the current page is requested by a tablet. |
| isDesktop | Boolean | TRUE if the visitor’s browser does not identify itself as a mobile or tablet device. |
| cmsContext | CmsPageContext |
An object with the following the Page, Template, and Site, which each have the following properties:
path(string)—name or ID of the CMS document.documentTypeFQN(string)—thedocumentTypesuch as “web_page”.document(pointer)—a pointer to the CMS document.
pageSize(int)—the maximum number of items to return in the collection.query(string)—A filter expression for Kibo eCommerce collections. You can filter products based on their properties by writing a string expression as your argument. For example:properties.firstname eq "Brenda".sortBy(string)—A string representing how to sort the collection. You can sort on any property, date (such ascreateDate), or document name. After specifying the name of the property you are sorting on, include a space followed by “asc” or “desc” to specify sorting in ascending or descending order.categoryId(int)—the category to facet products for.- A keyed collection of facets to filter on.
isAuthenticated(Boolean)—TRUE if the user is logged in.userId(string)—the unique identifier for the user.firstName(string)—the user’s first name.lastName(string)—the user’s last name.email(string)—the user’s email address.isAnonymous(Boolean)—TRUE if the user is not logged in.accountId(int)—the unique identifier of the user’s account.
items.navigation
Accesses the current navigation context.name(string)—the name of the node.url(string)—the URL to which the node links.index(int)—the unique identifier for the node.isHidden(Boolean)—TRUE if the node does not display in the site’s navigation bar.parent(NavigationNode)—the parent of the current node.items(list of NavigationNode)—the children of the current node.
tree, except it only includes the root-level or top level of the tree, and also excludes CMS pages and external links. |
| currentNode | NavigationNode | The current node in the tree. |
| breadcrumbs | NavigationNode array | Shows the “breadcrumbs” that navigate to the current page. This is the same as the tree but it excludes the parent and items properties. |
Example:
Context Methods Available to All Storefront Actions
exec.loginUser
Asynchronously retrieves a user, creates an authentication ticket, and sets the authentication cookies.userId(string)—The 32-character alphanumeric ID of the user to authenticate.userName(string)—The username of the user to authenticate (this field is not required if you provide auserId).rememberUser(Boolean)—Specifies whether the authentication cookie should be persistent.
errAn error object if the user is not found.dataThe authentication ticket for the user.
exec.logOut
Synchronously logs out the current user by resetting the user context to an anonymous user and updating the associated cookies.
Example:
Context Methods Available to All HTTP Actions
request.get
Returns an HTTP header value for the specified header key.
Example:
response.get
Gets a field from the response.
Example:
response.set
Sets the HTTP headers for the response.
Example:
response.set2
Updates a field in the response.
Example:
response.remove
Removes an HTTP header from the response.
Example:
response.redirect
Redirects the incoming URL.
Example:
response.end
Ends the response so that other actions or Kibo eCommerce logic can run. Also, signals the callback to complete.
Example:
get.resource
Returns the currently persisted value of the requested resource. **Not available for all calls.
Example:
get.resourceStatus
Gets the HTTP resource status.
Example:
items.urlHelper.getUrl
Gets the current URL.
Example:
Context Objects Available to All Actions
apiContext
Accesses Kibo eCommerce tenant information.
Example:
configuration
Receives a JSON response that contains information about the configuration data set in the Action Management JSON editor.
Example:

