Добрый день
Столкнулся с проблемой. Нужно запретить пользователю добавить в корзину больше чем товара есть в наличии.
Пробовал сделать это через модификацию файла /catalog/view/javascript/common.js в функцию
addToCart но ничего не получилось. Вот мой код:
<script type="text/javascript">
$('#button-cart').bind('click', function() {
q = document.getElementById('quantity').value;
m = document.getElementById('stockss').value;
if(q<=m){
$.ajax({
url: 'index.php?route=checkout/cart/add',
type: 'post',
data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea'),
dataType: 'json',
success: function(json) {
$('.success, .warning, .attention, information, .error').remove();
if (json['error']) {
if (json['error']['option']) {
for (i in json['error']['option']) {
$('#option-' + i).after('<span class="error">' + json['error']['option'][i] + '</span>');
}
}
}
if (json['success']) {
$('#notification').append('<div class="success-new" style="display: none;">' + json['success'] + '</div>');
$('.success-new').fadeIn('slow').delay(4000).slideUp(2000, function() {$(this).remove();});
$('#cart-total').html(json['total']);
$('.product-info .cart .wishlist-box').fadeOut('fast',function () {
}
}
});
}else{
$('#notification').append('<div class="success-new" style="display: none;">Заказано больше чем есть в наличии!</div>');
$('.success-new').fadeIn('slow').delay(4000).slideUp(2000, function() {$(this).remove();});
}
});
</script>
Прошу помощи.
ocStore: 1.5.3.1