[Skip to main content](#vessel-content)

#   How to increase/decrease quantity in cart

##

- **[YakNarak](/forum/user/476-yaknarak "View YakNarak's Profile")**
- [![YakNarak's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/476-yaknarak "View YakNarak's Profile") Topic Author
- [ Offline](/forum/user/476-yaknarak)

Less More

- Posts: 86
- Thank you received: 0
-
-

15 years 8 months ago [\#9216](#9216) by [YakNarak](/forum/user/476-yaknarak "View YakNarak's Profile")  *[How to increase/decrease quantity in cart](/forum/4-how-to/9216-how-to-increase-decrease-quantity-in-cart#9216 "Nicolas,  I'm trying to achieve a feature in the cart view that allows the user to increase/decrease the quantity in steps of 1. Or to delete the product entirely.  I've changed the code to this:  input id=&quot;hikashop&#95;checkout&#95;quantity&#95;&amp;lt;?php echo $row-&amp;gt;cart&#95;product&#95;id;?&amp;gt;&quot; type=&quot;text&quot; name=&quot;item&#91;cart&#95;product&#95;id;?&gt;&#93;&quot; class=&quot;hikashop&#95;product&#95;quantity&#95;field&quot; value=&quot;cart&#95;product&#95;quantity; ?&gt;&quot; onchange=&quot;this.form.submit(); return false;&quot; /&gt; params-&gt;get('show&#95;delete',1)){ ?&gt; a href=&quot;&amp;lt;?php echo hikashop::cmpleteLink('product&amp;task=updatecart&amp;product&#95;id='.$row-&amp;gt;product&#95;id.'&amp;quantity=0&amp;return&#95;url='.urlencode(base64&#95;encode(urldecode($this-&amp;gt;params-&amp;gt;get('url'))))); ?&amp;gt;&quot; onclick=&quot;var qty&#95;field = document.getElementById('hikashop&#95;checkout&#95;quantity&#95;cart&#95;product&#95;id;?&gt;'); qty&#95;field.value=0; qty&#95;field.form.submit(); return false;&quot; &gt;  params-&gt;get('show&#95;delete',1)){ ?&gt; a href=&quot;&amp;lt;?php echo hikashop::cmpleteLink('product&amp;task=updatecart&amp;product&#95;id='.$row-&amp;gt;product&#95;id.'&amp;quantity=0&amp;return&#95;url='.urlencode(base64&#95;encode(urldecode($this-&amp;gt;params-&amp;gt;get('url'))))); ?&amp;gt;&quot; onclick=&quot;var qty&#95;field = document.getElementById('hikashop&#95;checkout&#95;quantity&#95;cart&#95;product&#95;id;?&gt;'); qty&#95;field.value=qty&#95;field.value + 1; qty&#95;field.form.submit(); return false;&quot; &gt;  params-&gt;get('show&#95;delete',1)){ ?&gt; a href=&quot;&amp;lt;?php echo hikashop::cmpleteLink('product&amp;task=updatecart&amp;product&#95;id='.$row-&amp;gt;product&#95;id.'&amp;quantity=0&amp;return&#95;url='.urlencode(base64&#95;encode(urldecode($this-&amp;gt;params-&amp;gt;get('url'))))); ?&amp;gt;&quot; onclick=&quot;var qty&#95;field = document.getElementById('hikashop&#95;checkout&#95;quantity&#95;cart&#95;product&#95;id;?&gt;'); qty&#95;field.value=qty&#95;field.value - 1; qty&#95;field.form.submit(); return false;&quot; &gt;  All is showing well and the functions remove completely and subtract work correctly. However when I try to add something strange happens. Suppose the old value of the quantity field is 8. When I press the add button it shortly shows in the quantity field 81 instead of 9 Then the page refreshes and the value shows 10. I've tried this with several numbers. So if the old value was 12 and I press add, it shows 121, then refreshes and shows 10 again.  Any idea what goes wrong here?  Gert.")* was created by *[YakNarak](/forum/user/476-yaknarak "View YakNarak's Profile")*

Nicolas,

I'm trying to achieve a feature in the cart view that allows the user to increase/decrease the quantity in steps of 1. Or to delete the product entirely.

I've changed the code to this:

&lt;input id="hikashop_checkout_quantity_&lt;?php echo $row-&gt;cart_product_id;?&gt;" type="text" name="item[&lt;?php echo $row-&gt;cart_product_id;?&gt;]" class="hikashop_product_quantity_field" value="&lt;?php echo $row-&gt;cart_product_quantity; ?&gt;" onchange="this.form.submit(); return false;" /&gt;
&lt;?php if($this-&gt;params-&gt;get('show_delete',1)){ ?&gt;
&lt;a href="&lt;?php echo hikashop::completeLink('product&amp;task=updatecart&amp;product_id='.$row-&gt;product_id.'&amp;quantity=0&amp;return_url='.urlencode(base64_encode(urldecode($this-&gt;params-&gt;get('url'))))); ?&gt;" onclick="var qty_field = document.getElementById('hikashop_checkout_quantity_&lt;?php echo $row-&gt;cart_product_id;?&gt;'); qty_field.value=0; qty_field.form.submit(); return false;" &gt;&lt;img src="&lt;?php echo HIKASHOP_IMAGES . 'delete2.png';?&gt;" border="0" title="totally remove from cart" alt="totally remove product" /&gt;&lt;/a&gt;
&lt;?php } ?&gt;
&lt;?php if($this-&gt;params-&gt;get('show_delete',1)){ ?&gt;
&lt;a href="&lt;?php echo hikashop::completeLink('product&amp;task=updatecart&amp;product_id='.$row-&gt;product_id.'&amp;quantity=0&amp;return_url='.urlencode(base64_encode(urldecode($this-&gt;params-&gt;get('url'))))); ?&gt;" onclick="var qty_field = document.getElementById('hikashop_checkout_quantity_&lt;?php echo $row-&gt;cart_product_id;?&gt;'); qty_field.value=qty_field.value + 1; qty_field.form.submit(); return false;" &gt;&lt;img src="&lt;?php echo HIKASHOP_IMAGES . 'add1.png';?&gt;" border="0" title="add 1 unit to cart" alt="add 1 product" /&gt;&lt;/a&gt;
&lt;?php } ?&gt;
&lt;?php if($this-&gt;params-&gt;get('show_delete',1)){ ?&gt;
&lt;a href="&lt;?php echo hikashop::completeLink('product&amp;task=updatecart&amp;product_id='.$row-&gt;product_id.'&amp;quantity=0&amp;return_url='.urlencode(base64_encode(urldecode($this-&gt;params-&gt;get('url'))))); ?&gt;" onclick="var qty_field = document.getElementById('hikashop_checkout_quantity_&lt;?php echo $row-&gt;cart_product_id;?&gt;'); qty_field.value=qty_field.value - 1; qty_field.form.submit(); return false;" &gt;&lt;img src="&lt;?php echo HIKASHOP_IMAGES . 'subtract1.png';?&gt;" border="0" title="remove 1 unit from cart" alt="remove 1 product" /&gt;&lt;/a&gt;

All is showing well and the functions remove completely and subtract work correctly. However when I try to add something strange happens. Suppose the old value of the quantity field is 8. When I press the add button it shortly shows in the quantity field 81 instead of 9 Then the page refreshes and the value shows 10. I've tried this with several numbers. So if the old value was 12 and I press add, it shows 121, then refreshes and shows 10 again.

Any idea what goes wrong here?

Gert.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkyMTYtaG93LXRvLWluY3JlYXNlLWRlY3JlYXNlLXF1YW50aXR5LWluLWNhcnQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86561
- Thank you received: 14307
-
-

15 years 8 months ago [\#9226](#9226) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: How to increase/decrease quantity in cart](/forum/4-how-to/9216-how-to-increase-decrease-quantity-in-cart#9226 "Nicolas,  I'm trying to achieve a feature in the cart view that allows the user to increase/decrease the quantity in steps of 1. Or to delete the product entirely.  I've changed the code to this:  input id=&quot;hikashop&#95;checkout&#95;quantity&#95;&amp;lt;?php echo $row-&amp;gt;cart&#95;product&#95;id;?&amp;gt;&quot; type=&quot;text&quot; name=&quot;item&#91;cart&#95;product&#95;id;?&gt;&#93;&quot; class=&quot;hikashop&#95;product&#95;quantity&#95;field&quot; value=&quot;cart&#95;product&#95;quantity; ?&gt;&quot; onchange=&quot;this.form.submit(); return false;&quot; /&gt; params-&gt;get('show&#95;delete',1)){ ?&gt; a href=&quot;&amp;lt;?php echo hikashop::cmpleteLink('product&amp;task=updatecart&amp;product&#95;id='.$row-&amp;gt;product&#95;id.'&amp;quantity=0&amp;return&#95;url='.urlencode(base64&#95;encode(urldecode($this-&amp;gt;params-&amp;gt;get('url'))))); ?&amp;gt;&quot; onclick=&quot;var qty&#95;field = document.getElementById('hikashop&#95;checkout&#95;quantity&#95;cart&#95;product&#95;id;?&gt;'); qty&#95;field.value=0; qty&#95;field.form.submit(); return false;&quot; &gt;  params-&gt;get('show&#95;delete',1)){ ?&gt; a href=&quot;&amp;lt;?php echo hikashop::cmpleteLink('product&amp;task=updatecart&amp;product&#95;id='.$row-&amp;gt;product&#95;id.'&amp;quantity=0&amp;return&#95;url='.urlencode(base64&#95;encode(urldecode($this-&amp;gt;params-&amp;gt;get('url'))))); ?&amp;gt;&quot; onclick=&quot;var qty&#95;field = document.getElementById('hikashop&#95;checkout&#95;quantity&#95;cart&#95;product&#95;id;?&gt;'); qty&#95;field.value=qty&#95;field.value + 1; qty&#95;field.form.submit(); return false;&quot; &gt;  params-&gt;get('show&#95;delete',1)){ ?&gt; a href=&quot;&amp;lt;?php echo hikashop::cmpleteLink('product&amp;task=updatecart&amp;product&#95;id='.$row-&amp;gt;product&#95;id.'&amp;quantity=0&amp;return&#95;url='.urlencode(base64&#95;encode(urldecode($this-&amp;gt;params-&amp;gt;get('url'))))); ?&amp;gt;&quot; onclick=&quot;var qty&#95;field = document.getElementById('hikashop&#95;checkout&#95;quantity&#95;cart&#95;product&#95;id;?&gt;'); qty&#95;field.value=qty&#95;field.value - 1; qty&#95;field.form.submit(); return false;&quot; &gt;  All is showing well and the functions remove completely and subtract work correctly. However when I try to add something strange happens. Suppose the old value of the quantity field is 8. When I press the add button it shortly shows in the quantity field 81 instead of 9 Then the page refreshes and the value shows 10. I've tried this with several numbers. So if the old value was 12 and I press add, it shows 121, then refreshes and shows 10 again.  Any idea what goes wrong here?  Gert.")*

qty_field.value=qty_field.value + 1;

is not correct javascript. It should be:
qty_field.value=parseInt(qty_field.value) + 1;

Otherwise, that will add 1 to the string 10 and you will get 101 instead of 11.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkyMTYtaG93LXRvLWluY3JlYXNlLWRlY3JlYXNlLXF1YW50aXR5LWluLWNhcnQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[YakNarak](/forum/user/476-yaknarak "View YakNarak's Profile")**
- [![YakNarak's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/476-yaknarak "View YakNarak's Profile") Topic Author
- [ Offline](/forum/user/476-yaknarak)

Less More

- Posts: 86
- Thank you received: 0
-
-

15 years 8 months ago [\#9237](#9237) by [YakNarak](/forum/user/476-yaknarak "View YakNarak's Profile")  Replied by *[YakNarak](/forum/user/476-yaknarak "View YakNarak's Profile")* on topic *[Re: How to increase/decrease quantity in cart](/forum/4-how-to/9216-how-to-increase-decrease-quantity-in-cart#9237 "Nicolas,  I'm trying to achieve a feature in the cart view that allows the user to increase/decrease the quantity in steps of 1. Or to delete the product entirely.  I've changed the code to this:  input id=&quot;hikashop&#95;checkout&#95;quantity&#95;&amp;lt;?php echo $row-&amp;gt;cart&#95;product&#95;id;?&amp;gt;&quot; type=&quot;text&quot; name=&quot;item&#91;cart&#95;product&#95;id;?&gt;&#93;&quot; class=&quot;hikashop&#95;product&#95;quantity&#95;field&quot; value=&quot;cart&#95;product&#95;quantity; ?&gt;&quot; onchange=&quot;this.form.submit(); return false;&quot; /&gt; params-&gt;get('show&#95;delete',1)){ ?&gt; a href=&quot;&amp;lt;?php echo hikashop::cmpleteLink('product&amp;task=updatecart&amp;product&#95;id='.$row-&amp;gt;product&#95;id.'&amp;quantity=0&amp;return&#95;url='.urlencode(base64&#95;encode(urldecode($this-&amp;gt;params-&amp;gt;get('url'))))); ?&amp;gt;&quot; onclick=&quot;var qty&#95;field = document.getElementById('hikashop&#95;checkout&#95;quantity&#95;cart&#95;product&#95;id;?&gt;'); qty&#95;field.value=0; qty&#95;field.form.submit(); return false;&quot; &gt;  params-&gt;get('show&#95;delete',1)){ ?&gt; a href=&quot;&amp;lt;?php echo hikashop::cmpleteLink('product&amp;task=updatecart&amp;product&#95;id='.$row-&amp;gt;product&#95;id.'&amp;quantity=0&amp;return&#95;url='.urlencode(base64&#95;encode(urldecode($this-&amp;gt;params-&amp;gt;get('url'))))); ?&amp;gt;&quot; onclick=&quot;var qty&#95;field = document.getElementById('hikashop&#95;checkout&#95;quantity&#95;cart&#95;product&#95;id;?&gt;'); qty&#95;field.value=qty&#95;field.value + 1; qty&#95;field.form.submit(); return false;&quot; &gt;  params-&gt;get('show&#95;delete',1)){ ?&gt; a href=&quot;&amp;lt;?php echo hikashop::cmpleteLink('product&amp;task=updatecart&amp;product&#95;id='.$row-&amp;gt;product&#95;id.'&amp;quantity=0&amp;return&#95;url='.urlencode(base64&#95;encode(urldecode($this-&amp;gt;params-&amp;gt;get('url'))))); ?&amp;gt;&quot; onclick=&quot;var qty&#95;field = document.getElementById('hikashop&#95;checkout&#95;quantity&#95;cart&#95;product&#95;id;?&gt;'); qty&#95;field.value=qty&#95;field.value - 1; qty&#95;field.form.submit(); return false;&quot; &gt;  All is showing well and the functions remove completely and subtract work correctly. However when I try to add something strange happens. Suppose the old value of the quantity field is 8. When I press the add button it shortly shows in the quantity field 81 instead of 9 Then the page refreshes and the value shows 10. I've tried this with several numbers. So if the old value was 12 and I press add, it shows 121, then refreshes and shows 10 again.  Any idea what goes wrong here?  Gert.")*

Nicolas,

Once more big thanks. Working now.

Gert.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkyMTYtaG93LXRvLWluY3JlYXNlLWRlY3JlYXNlLXF1YW50aXR5LWluLWNhcnQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.050 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
