Skip to content

Commit

Permalink
Merge pull request #363 from Nosto/CFE-745-align-nostojs-functions
Browse files Browse the repository at this point in the history
CFE-745: use reportAddToCart and support string slotId parameter
  • Loading branch information
supercid authored Jan 17, 2025
2 parents b5d96ed + dfced12 commit 2e0de05
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions views/templates/hook/header_add-to-cart.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2e0de05

Please sign in to comment.