Проблема с Javascript и ISML-файлом
Это код, который разработчик написал ранее, и он работает не так, как ожидалось. Проблема в том, что когда товара нет в наличии, пользователь может добавить товары в корзину. Ниже приведен код и не уверен, что этого достаточно. В любом случае, здесь вы идете.
function checkInventory($el) {
var $qty = $el,
qty = $qty.val(),
$msg = $('.in-stock-msg');
if ($msg.length > 0) {
var inv = parseInt($msg.attr('data-inventory'), 10),
inMessage = $msg.attr('data-in-message'),
outMessage = $msg.attr('data-out-message');
if (qty > inv) {
// NO MORE INVENTORY
if ($msg.html() != outMessage) {
// SET OUTMESSAGE
$msg.html(outMessage);
$('.qty-plus').css('visibility','hidden');
}
// SET VAL
$qty.val(inv);
} else {
// INVENTORY OK
if ($msg.html() != inMessage) {
$msg.html(inMessage);
$('.qty-plus').css('visibility','visible');
}
}
}
}
<div class="availability-msg">
- <p class="${availabilityClass}" data-perpetual="${inventoryRecord != null && inventoryRecord.perpetual ? 1 : 0}" data-out-message="${Resource.msg('global.allnotavailable', 'locale', null)}" data-inventory="${(inventoryRecord != null && (inventoryRecord.stockLevel.available || inventoryRecord.perpetual)) ? inventoryRecord.getStockLevel().value : 0}"><isprint value="${availabilityMsg}" encoding="off"/></p>
+ <p class="${availabilityClass}" data-perpetual="${inventoryRecord != null && inventoryRecord.perpetual ? 1 : 0}" data-in-message="<isprint value="${availabilityMsg}" encoding="off"/>" data-out-message="${Resource.msg('global.allnotavailable', 'locale', null)}" data-inventory="${(inventoryRecord != null && (inventoryRecord.stockLevel.available || inventoryRecord.perpetual)) ? inventoryRecord.getStockLevel().value : 0}"><isprint value="${availabilityMsg}" encoding="off"/></p>
<isif condition="${inStockDateMsg}"><p class="in-stock-date-msg">${inStockDateMsg}</p></isif>
Add a comment to this line
</div>