UNPKG

@klevu/core

Version:

Typescript SDK that simplifies development on Klevu backend. Klevu provides advanced AI-powered search and discovery solutions for online retailers.

42 lines (41 loc) 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.boughtTogether = void 0; const KlevuTypeOfRecord_js_1 = require("../../models/KlevuTypeOfRecord.js"); const KlevuTypeOfRequest_js_1 = require("../../models/KlevuTypeOfRequest.js"); const defaultOptions = { limit: 5, }; /** * Bought together recommendation on checkout page * * @category RecommendationQuery * @param options * @param modifiers * @returns */ function boughtTogether(productIdsInCart, options, ...modifiers) { const opts = Object.assign(Object.assign({}, defaultOptions), options); const query = { id: "boughtTogether", typeOfRequest: KlevuTypeOfRequest_js_1.KlevuTypeOfRequest.AlsoBought, settings: { limit: opts.limit, typeOfRecords: [KlevuTypeOfRecord_js_1.KlevuTypeOfRecord.Product], context: { recentObjects: [ { typeOfRecord: KlevuTypeOfRecord_js_1.KlevuTypeOfRecord.Product, records: productIdsInCart.map((id) => ({ id })), }, ], }, }, }; return { klevuFunctionId: "recommendation", queries: [query], modifiers, }; } exports.boughtTogether = boughtTogether;