Добрый день, правлю файл product.tpl добавляю кнопку купить, все вроде работает нормально но у некоторых продуктов есть поля опции при выборе опции товар в таблицу не добавляется как можно исправить.
Спасибо.
Код кнопки:
<a onclick="addToCart('<?php echo $product_id ?>');">
<span>Add to cart</span>
<div class="clear"></div>
</a>
Код функции:
function addToCart(product_id, quantity) {
quantity = typeof(quantity) != 'undefined' ? quantity : 1;
jQuery.ajax({
url: 'index.php?route=checkout/cart/add',
type: 'post',
data: 'product_id=' + product_id + '&quantity=' + quantity,
dataType: 'json',
success: function(json) {
jQuery('.success, .warning, .attention, .information, .error').remove();
if (json['redirect']) {
location = json['redirect'];
}
if (json['success']) {
jQuery('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
jQuery('.success').fadeIn('slow');
jQuery('#cart-total').html(json['total']);
jQuery('html, body').animate({ scrollTop: 0 }, 'slow');
}
}
});
}
Где необходимо докрутить.