### get(name, arguments) Source: https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/sfrajsdoc/js/server/Server.html A shortcut method to 'use' that specifically handles GET requests, adding a check for the GET HTTP method. ```APIDOC ## get(name, arguments) ### Description Shortcut to "use" method that adds a check for get request. ### Parameters #### Path Parameters - **name** (string) - Required - Name of the route - **arguments** (Array.) - Required - List of functions to be executed ### Returns Type: void ### Source * modules/server/server.js, line 114 ``` -------------------------------- ### loadRecommendations() Source: https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/sfrajsdoc/js/client/global.html Gets all placeholder elements, which hold Einstein recommendations queries, retrieves details from the Einstein engine, and feeds them back to the DOM element. ```APIDOC ## loadRecommendations() ### Description Gets all placeholder elements, which hold einstein recommendations queries the details from the einstein engine and feeds them back to the dom element ``` -------------------------------- ### Get Customer Profile Information Source: https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/sfrajsdoc/js/server/app_storefront_base_cartridge_models_account.js.html Creates a plain object containing the customer's profile details. Returns null if no profile is provided. ```javascript "use strict"; var AddressModel = require('*/cartridge/models/address'); var URLUtils = require('dw/web/URLUtils'); /** * Creates a plain object that contains profile information * @param {Object} profile - current customer's profile * @returns {Object} an object that contains information about the current customer's profile */ function getProfile(profile) { var result; if (profile) { result = { firstName: profile.firstName, lastName: profile.lastName, email: profile.email, phone: profile.phone, password: '********' }; } else { result = null; } return result; } ``` -------------------------------- ### Show More Bonus Products Source: https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/sfrajsdoc/js/client/product_base.js.html Handles the click event for 'show-more-bonus-products'. It initiates an AJAX GET request to fetch more bonus products and displays a spinner during the request. ```javascript var url = $(this).data('url'); $('.modal-content').spinner().start(); $.ajax({ url: url, method: 'GET', success: function (html) { ``` -------------------------------- ### Default-Start Source: https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/sfrajsdoc/js/server/app_storefront_base_cartridge_controllers_Default.js.html Renders the homepage. This endpoint is executed when opening the site directly from Business Manager or when a sitepath is defined in site aliases. ```APIDOC ## Default-Start ### Description This endpoint is the root of the site and is executed when opening from Business Manager or when a sitepath is defined in the site aliases. It renders the homepage. ### Method GET ### Endpoint / ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - Renders the `/home/homePage` ISML template. #### Response Example None ``` -------------------------------- ### Retrieve Search Suggestions with AJAX Source: https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/sfrajsdoc/js/client/components_search.js.html Fetches search suggestions from a specified endpoint using AJAX. It starts a spinner, makes a GET request, and processes the response. If the input length is less than 'minChars', it clears suggestions and resets the UI. ```javascript function getSuggestions(scope) { if ($(scope).val().length >= minChars) { $.spinner().start(); $.ajax({ context: scope, url: endpoint + encodeURIComponent($(scope).val()), method: 'GET', success: processResponse, error: function () { $.spinner().stop(); } }); } else { toggleSuggestionsIcon('search'); $(scope).siblings('.reset-button').removeClass('d-sm-block'); clearModals(); getSuggestionsWrapper(scope).empty(); } } ``` -------------------------------- ### Server Constructor Source: https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/sfrajsdoc/js/server/Server.html Initializes a new instance of the Server class. This is the entry point for creating a server instance. ```APIDOC ## new Server() ### Description Initializes a new instance of the Server class. ### Source * modules/server/server.js, line 40 ``` -------------------------------- ### get Source: https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/sfrajsdoc/js/server/global.html Middleware filter specifically for GET requests. ```APIDOC ## get(req, res, next) ### Description Middleware filter for get requests. ### Parameters #### Path Parameters - `req` (Object) - Required - Request object - `res` (Object) - Required - Response object - `next` (function) - Required - Next call in the middleware chain ### Returns Type: void ``` -------------------------------- ### setupSearch Source: https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/sfrajsdoc/js/server/global.html Set search configuration values. ```APIDOC ## setupSearch(apiProductSearch, params, httpParameterMap) ### Description Set search configuration values. ### Parameters #### Path Parameters - **apiProductSearch** (dw.catalog.ProductSearchModel) - API search instance - **params** (Object) - Provided HTTP query parameters - **httpParameterMap** (Object) - Query params ``` -------------------------------- ### get Middleware Source: https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/sfrajsdoc/js/server/modules_server_middleware.js.html Middleware function to filter GET requests. It checks if the request's HTTP method is 'GET' and proceeds to the next middleware or throws an error. ```APIDOC ## get ### Description Middleware function to filter GET requests. It checks if the request's HTTP method is 'GET' and proceeds to the next middleware or throws an error. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) Calls the next middleware in the chain. #### Response Example None ``` -------------------------------- ### Setup Product Search Model Source: https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/sfrajsdoc/js/server/app_storefront_base_cartridge_scripts_helpers_searchHelpers.js.html Configures the ProductSearchModel with parameters from the request, including sorting rules, selected category, and preferences. Use this to initialize and customize product search behavior. ```javascript "use strict"; /** * Set search configuration values * * @param {dw.catalog.ProductSearchModel} apiProductSearch - API search instance * @param {Object} params - Provided HTTP query parameters * @return {dw.catalog.ProductSearchModel} - API search instance * @param {Object} httpParameterMap - Query params */ function setupSearch(apiProductSearch, params, httpParameterMap) { var CatalogMgr = require('dw/catalog/CatalogMgr'); var searchModelHelper = require('*/cartridge/scripts/search/search'); var sortingRule = params.srule ? CatalogMgr.getSortingRule(params.srule) : null; var selectedCategory = CatalogMgr.getCategory(params.cgid); selectedCategory = selectedCategory && selectedCategory.online ? selectedCategory : null; searchModelHelper.setProductProperties(apiProductSearch, params, selectedCategory, sortingRule, httpParameterMap); if (params.preferences) { searchModelHelper.addRefinementValues(apiProductSearch, params.preferences); } return apiProductSearch; } ``` -------------------------------- ### Product-ShowQuickView Source: https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/sfrajsdoc/js/server/Product.html This endpoint is called when a product quick view button is clicked. It uses cache middleware and requires a product ID. ```APIDOC ## Product-ShowQuickView ### Description This endpoint is called when a product quick view button is clicked. ### Method GET ### Endpoint /Product-ShowQuickView ### Parameters #### Query Parameters - **pid** (string) - Required - Product ID #### Middleware - **cache.applyPromotionSensitiveCache** ``` -------------------------------- ### GET Request Middleware Source: https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/sfrajsdoc/js/server/modules_server_middleware.js.html Filters requests to allow only GET HTTP methods. Use this middleware to protect routes that should not be accessed via other HTTP methods. ```javascript "use strict"; /** * Middleware filter for get requests * @param {Object} req - Request object * @param {Object} res - Response object * @param {Function} next - Next call in the middleware chain * @returns {void} */ function get(req, res, next) { if (req.httpMethod === 'GET') { next(); } else { next(new Error('Params do not match route')); } } ``` -------------------------------- ### Initialize Bonus Product Modal Source: https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/sfrajsdoc/js/client/product_base.js.html Prepares and displays a modal for selecting bonus products. It dynamically constructs the modal's HTML, including data attributes for configuration, and appends it to the DOM. ```javascript function chooseBonusProducts(data) { $('.modal-body').spinner().start(); if ($('#chooseBonusProductModal').length !== 0) { $('#chooseBonusProductModal').remove(); } var bonusUrl; if (data.bonusChoiceRuleBased) { bonusUrl = data.showProductsUrlRuleBased; } else { bonusUrl = data.showProductsUrlListBased; } var htmlString = '' + '