I modified it from this post in the Opencart 1.5 forum (thanks Xyph3r).
Put this somewhere in the page:
Code: Select all
<script type="text/javascript">
function addQtyToCart(product_id) {
var qty = $('.item-' + product_id).val();
if ((parseFloat(qty) != parseInt(qty)) || isNaN(qty)) {
qty = 1;
}
cart.add(product_id, qty);
}
</script>
Code: Select all
<button type="button" onclick="cart.add('{{ product.product_id }}', '{{ product.minimum }}');">
Code: Select all
<button type="button" class="btn module-product-btn-cart animation" onclick="addQtyToCart('{{ product.product_id }}');">
Code: Select all
<input type="text" value="1" size="2" class="item-{{ product.product_id }}" />