History: API Tracker Update Demo
Preview of version: 1
- «
- »
CODE(colors="javascript")}$(".stockAdmin.minus, .stockAdmin.plus")
.css("cursor", "pointer")
.on(
"click",
function () {
let itemId = location.href.match(/product-(\d+)/);
if (itemId) {
itemId = itemId1;
} else {
alert("No product id found");
return;
}
const $stockAdmin = $(".stockAdmin.number");
$stockAdmin.tikiModal(" ");
let stock = $stockAdmin.text();
if ($(this).hasClass("minus")) {
stock--;
} else {
stock++;
}
$.ajax(
$.service("tracker", "update_item"),
{
type: 'POST',
dataType: 'json',
data: {
fields: {
productsStock: stock
},
itemId: itemId,
trackerId: 1
},
success: function (data) {
if (!data) {
alert("Oops, something went wrong, sorry");
} else {
$stockAdmin.text(stock);
}
$(".stockAdmin.number").tikiModal();
}
}
);
return false;
})
{CODE}