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

#   Quantity selector

##

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

Less More

- Posts: 465
- Thank you received: 19
-

6 months 1 week ago [\#371509](#371509) by [Reincidente](/forum/user/12307-reincidente "View Reincidente's Profile")  *[Quantity selector](/forum/25-install-update/910449-quantity-selector#371509 "Hi Nicolas,  For the past few days I’ve noticed the following: on a product page, if you select a variant and set the quantity to 2 or more to add to the cart, then switch to another variant using the selector, the quantity field does not reset back to 1. Instead, it keeps the previously selected quantity by default.")* was created by *[Reincidente](/forum/user/12307-reincidente "View Reincidente's Profile")*

Hi Nicolas,

For the past few days I’ve noticed the following: on a product page, if you select a variant and set the quantity to 2 or more to add to the cart, then switch to another variant using the selector, the quantity field does not reset back to 1. Instead, it keeps the previously selected quantity by default.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI1LWluc3RhbGwtdXBkYXRlLzkxMDQ0OS1xdWFudGl0eS1zZWxlY3Rvcj90bXBsPW1hcmtkb3du) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14269
-
-

6 months 1 week ago [\#371510](#371510) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Quantity selector](/forum/25-install-update/910449-quantity-selector#371510 "Hi Nicolas,  For the past few days I’ve noticed the following: on a product page, if you select a variant and set the quantity to 2 or more to add to the cart, then switch to another variant using the selector, the quantity field does not reset back to 1. Instead, it keeps the previously selected quantity by default.")*

Hi,

This behavior is intentional.

This is an improvement we've made with the latest version of HikaShop where the JavaScript that swaps the variant content now saves the quantity value before the swap and restores it right after, so the quantity stays on whatever the customer had typed. We think that is the better default - if a customer has typed "2" and then picks a different size or color, forcing them to re-enter "2" every time adds unnecessary friction, and it is easy for them to miss the reset and end up ordering only one item.

If, in your specific case, you really want the quantity to reset to 1 on every variant change, you can add the following JavaScript snippet to your Joomla template (or to a custom module with JS output):
Code:

&lt;script&gt; document.addEventListener('DOMContentLoaded', function(){ if(window.Oby &amp;&amp; Oby.registerAjax) { Oby.registerAjax('hkContentChanged', function(){ var q = document.querySelector('#hikashop_product_quantity_main .hikashop_product_quantity_field'); if(q) q.value = 1; }); } }); &lt;/script&gt;

It hooks into the "hkContentChanged" event that is fired right after the variant swap and sets the main quantity field back to 1.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI1LWluc3RhbGwtdXBkYXRlLzkxMDQ0OS1xdWFudGl0eS1zZWxlY3Rvcj90bXBsPW1hcmtkb3du) 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.171 seconds

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

[](#top)
