Skip to content

Commit

Permalink
Merge branch 'develop' into fix/php-handle-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
supercid authored Feb 7, 2025
2 parents 91aadad + b7a621c commit 4bbaa88
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 123 deletions.
148 changes: 37 additions & 111 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 13 additions & 12 deletions view/frontend/web/js/recobuy.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ define([
};

// Product object must have fields productId and skuId {'productId': '123', 'skuId': '321'}
Recobuy.addSkuToCart = function (product, element) {
Recobuy.addSkuToCart = function (product, element, _quantity) {

const quantity = product.quantity || 1;
const quantity = product.quantity || _quantity || 1;
const url = document.querySelector("#nosto_addtocart_form").getAttribute("action");
const formKey = document.querySelector("#nosto_addtocart_form > input[name='form_key']").getAttribute("value");

Expand All @@ -86,7 +86,7 @@ define([
'sku': product.skuId,
},
success: function () {
Recobuy.sendCartEvent(element, product.productId)
Recobuy.sendCartEvent(element, product)
return resolve()
},
error: function () {
Expand All @@ -97,19 +97,20 @@ define([

};

Recobuy.sendCartEvent = function (element, productId) {
if (typeof element === 'object' && element) {
const slotId = this.resolveContextSlotId(element);
if (slotId) {
nostojs(function (api) {
// noinspection JSUnresolvedFunction
api.recommendedProductAddedToCart(productId, slotId);
});
}
Recobuy.sendCartEvent = function (element, product) {
const slotId = this.resolveContextSlotId(element);
if (slotId) {
nostojs(function (api) {
// noinspection JSUnresolvedFunction
api.reportAddToCart(product, slotId);
});
}
}

Recobuy.resolveContextSlotId = function (element) {
if (!element || typeof element === "string") {
return element;
}
const m = 20;
let n = 0;
let e = element;
Expand Down

0 comments on commit 4bbaa88

Please sign in to comment.