title: Open Cart version 2, Quantity filed on Category View
body: <p>I am working with Opencart 2.0 and I am trying to get the quantity field to work from the category page as well as the product pages. I managed to do this fine previously with version 1.5 but the code has changed a lot since.
  With Opencart V 1.5 I used the solution provided by Siven Sadiyan (<a href="http://siven76.com/2013/04/29/opencart-add-a-quantity-box-on-product-list-pages/" rel="nofollow">http://siven76.com/2013/04/29/opencart-add-a-quantity-box-on-product-list-pages/</a>) who's solution worked beautifully, and just required a tweak to common.js and category.tpl and I was able to apply this to various other pages too such as search results and modules.
  I have been unable so far to modify this to suit Opencart version 2.0+ as the code and terms have changed. I have tried several extensions but there seems to be little working solutions at the moment except for hard coding it and manually, and so far it is not going well for me! All I am looking for is functionality and I am not worried about the layout.</p>
  
  <p>The common.js file has changed since the solution to the previous version of Opencart and I know it involves the following code (ps, scroll to top is removed from the below code but only one line has changed from the original):</p>
  
  <pre><code> // Cart add remove functions
   var cart = {
       'add': function(product_id, quantity) {
           jQuery.ajax({
               url: 'index.php?option=com_mijoshop&amp;route=checkout/cart/add&amp;format=raw&amp;tmpl=component',
               type: 'post',
               data: 'product_id=' + product_id + '&amp;quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
               dataType: 'json',
               beforeSend: function() {
                   jQuery('#cart &gt; button').button('loading');
               },
               success: function(json) {
                   jQuery('.alert, .text-danger').remove();
  
                  jQuery('#cart &gt; button').button('reset');
  
                  if (json['redirect']) {
                      location = json['redirect'];
                  }
  
                  if (json['success']) {
                      jQuery('#content_oc').parent().before('&lt;div class="shopnotification"&gt;&lt;i class="fa fa-check-circle"&gt;&lt;/i&gt; ' + json['success'] + '&lt;button      type="button" class="close" data-dismiss="alert"&gt;&amp;times;&lt;/button&gt;&lt;/div&gt;');
  
                      jQuery('#cart-total,#cart &gt; a &gt; span').html(json['total']);
  
                      jQuery('.shopnotification').fadeIn(1000).delay(3000).fadeOut(1500);
  
                      jQuery('#cart &gt; ul,#module_cart &gt; ul').load('index.php?option=com_mijoshop&amp;route=common/cart/info&amp;format=raw&amp;tmpl=component ul li');
                  }
               }
           });
       },
  </code></pre>
  
  <p>The second file is category.tpl code (which I presume when successfully changed can be altered in other areas):</p>
  
  <pre><code> &lt;div class="button-group"&gt;
       &lt;button type="button" onclick="cart.add('&lt;?php echo $product['product_id']; ?&gt;');"&gt;&lt;i class="fa fa-shopping-cart"&gt;&lt;/i&gt; &lt;span class="hidden-xs hidden-sm hidden-md"&gt;&lt;?php echo $button_cart; ?&gt;&lt;/span&gt;&lt;/button&gt;
       &lt;button type="button" data-toggle="tooltip" title="&lt;?php echo $button_wishlist; ?&gt;" onclick="wishlist.add('&lt;?php echo $product['product_id']; ?&gt;');"&gt;&lt;i class="fa fa-heart"&gt;&lt;/i&gt;&lt;/button&gt;
       &lt;button type="button" data-toggle="tooltip" title="&lt;?php echo $button_compare; ?&gt;" onclick="compare.add('&lt;?php echo $product['product_id']; ?&gt;');"&gt;&lt;i class="fa fa-exchange"&gt;&lt;/i&gt;&lt;/button&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>Anyone with a solution for this it would be appreciated! I will post back if I get any luck myself but I'm low on coffee after a long head scratch!</p>