From dfced12378234f66154e7d31cd32f604692a8ce5 Mon Sep 17 00:00:00 2001 From: Manikandan Ravikumar Date: Thu, 16 Jan 2025 16:15:22 +0200 Subject: [PATCH] use reportAddToCart and support string slotId parameter --- views/templates/hook/header_add-to-cart.tpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/views/templates/hook/header_add-to-cart.tpl b/views/templates/hook/header_add-to-cart.tpl index e8e6635b..49671723 100644 --- a/views/templates/hook/header_add-to-cart.tpl +++ b/views/templates/hook/header_add-to-cart.tpl @@ -40,11 +40,11 @@ //Product object must have fields productId and skuId productId: 123, skuId: 321 Nosto.addSkuToCart = function (product, element, quantity) { quantity = quantity || 1; - if (typeof nostojs !== 'undefined' && typeof element === 'object') { + if (typeof nostojs !== 'undefined') { var slotId = Nosto.resolveContextSlotId(element); if (slotId) { nostojs(function (api) { - api.recommendedProductAddedToCart(product.productId, slotId); + api.reportAddToCart(product, slotId); }); } } @@ -93,8 +93,8 @@ }; Nosto.resolveContextSlotId = function (element) { - if (!element) { - return false; + if (!element || typeof element === "string") { + return element; } var m = 20; var n = 0;