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

#   Quantity Dropdown to Match Quantity of Product

##

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

Less More

- Posts: 966
- Thank you received: 11
-
-

9 years 2 months ago [\#277901](#277901) by [MyWorld](/forum/user/862-myworld "View MyWorld's Profile")  *[Quantity Dropdown to Match Quantity of Product](/forum/25-install-update/891851-quantity-dropdown-to-match-quantity-of-product#277901 "-- HikaShop version -- : 3.1.1 -- Joomla version -- : 3.7.5  Is it possible to have the quantity dropdown display the amount of quantity available for that item?  Currently the dropdown is always showing 15. Example, if I have 3 bags, then it should only go up to 3, if I have 5 earrings then it only goes up to 5, etc...  Thanks!!")* was created by *[MyWorld](/forum/user/862-myworld "View MyWorld's Profile")*

-- HikaShop version -- : 3.1.1
-- Joomla version -- : 3.7.5

Is it possible to have the quantity dropdown display the amount of quantity available for that item?

Currently the dropdown is always showing 15. Example, if I have 3 bags, then it should only go up to 3, if I have 5 earrings then it only goes up to 5, etc...

Thanks!!

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

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Away](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26395
- Thank you received: 4077
-
- [](http://obsi.dev)
-

9 years 2 months ago [\#277902](#277902) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Quantity Dropdown to Match Quantity of Product](/forum/25-install-update/891851-quantity-dropdown-to-match-quantity-of-product#277902 "-- HikaShop version -- : 3.1.1 -- Joomla version -- : 3.7.5  Is it possible to have the quantity dropdown display the amount of quantity available for that item?  Currently the dropdown is always showing 15. Example, if I have 3 bags, then it should only go up to 3, if I have 5 earrings then it only goes up to 5, etc...  Thanks!!")*

Hello,

We would need more details about the context, the quantity layout you're using, your HikaShop configuration (legacy or not), the product you're talking about and it's settings.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

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

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

Less More

- Posts: 966
- Thank you received: 11
-
-

9 years 2 months ago [\#277988](#277988) by [MyWorld](/forum/user/862-myworld "View MyWorld's Profile")  Replied by *[MyWorld](/forum/user/862-myworld "View MyWorld's Profile")* on topic *[Quantity Dropdown to Match Quantity of Product](/forum/25-install-update/891851-quantity-dropdown-to-match-quantity-of-product#277988 "-- HikaShop version -- : 3.1.1 -- Joomla version -- : 3.7.5  Is it possible to have the quantity dropdown display the amount of quantity available for that item?  Currently the dropdown is always showing 15. Example, if I have 3 bags, then it should only go up to 3, if I have 5 earrings then it only goes up to 5, etc...  Thanks!!")*

> your HikaShop configuration (legacy or not)

What is legacy? I assume mine is not legacy unless it was set as the default.

> The product you're talking about and it's settings.

I am talking about all products that will have a dropdown. I would like the dropdown to show the quantity of that product or product option. For example, say the item below has 2 small, 3 medium, and 5 large, when the user clicks on a size the quantity of that size will show in the dropdown.

So if they click on small, it will show:
1
2

If they click on large, it will show:
1
2
3
4
5

Etc....

[ ![quantity.jpg](/forum/attachment/40212) ](/forum/attachment/40212 "quantity.jpg")

- [ ![quantity.jpg](/forum/attachment/40212) ](/forum/attachment/40212 "quantity.jpg") [ ](/forum/attachment/40212?download=1 "quantity.jpg")

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

Less More

- Posts: 86360
- Thank you received: 14296
-
-

9 years 2 months ago [\#277993](#277993) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Quantity Dropdown to Match Quantity of Product](/forum/25-install-update/891851-quantity-dropdown-to-match-quantity-of-product#277993 "-- HikaShop version -- : 3.1.1 -- Joomla version -- : 3.7.5  Is it possible to have the quantity dropdown display the amount of quantity available for that item?  Currently the dropdown is always showing 15. Example, if I have 3 bags, then it should only go up to 3, if I have 5 earrings then it only goes up to 5, etc...  Thanks!!")*

Hi,

Try adding the code: Code:

if($this-&gt;row-&gt;product_quantity &gt; 0) $max_quantity = min($max_quantity, $this-&gt;row-&gt;product_quantity);

before the code: Code:

$min_quantity = max((int)$min_quantity, 1); $max_quantity = max((int)$max_quantity, 0);

in the file "show_quantity" via the menu Display&gt;Views.

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

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

Less More

- Posts: 966
- Thank you received: 11
-
-

9 years 1 month ago [\#278743](#278743) by [MyWorld](/forum/user/862-myworld "View MyWorld's Profile")  Replied by *[MyWorld](/forum/user/862-myworld "View MyWorld's Profile")* on topic *[Quantity Dropdown to Match Quantity of Product](/forum/25-install-update/891851-quantity-dropdown-to-match-quantity-of-product#278743 "-- HikaShop version -- : 3.1.1 -- Joomla version -- : 3.7.5  Is it possible to have the quantity dropdown display the amount of quantity available for that item?  Currently the dropdown is always showing 15. Example, if I have 3 bags, then it should only go up to 3, if I have 5 earrings then it only goes up to 5, etc...  Thanks!!")*

Did I do something wrong because it's not working. This is what I have.
Code:

&lt;?php $quantity_counter = $this-&gt;getQuantityCounter(); $id = 'hikashop_product_quantity_field_'.$quantity_counter; if($this-&gt;params-&gt;get('show_quantity_legacy', false)) { $i = (int)$this-&gt;params-&gt;get('i', 0); if($i &gt; 0) $id = 'hikashop_product_quantity_field_'.$i; } $name = 'quantity'; if(!empty($this-&gt;row-&gt;quantityFieldName)){ $name = $this-&gt;row-&gt;quantityFieldName; } if(isset($this-&gt;row) &amp;&amp; isset($this-&gt;row-&gt;product_min_per_order)) { $min_quantity = ($this-&gt;row-&gt;product_min_per_order &#124;&#124; empty($this-&gt;element-&gt;main)) ? $this-&gt;row-&gt;product_min_per_order : $this-&gt;element-&gt;main-&gt;product_min_per_order; $max_quantity = ($this-&gt;row-&gt;product_max_per_order &#124;&#124; empty($this-&gt;element-&gt;main)) ? $this-&gt;row-&gt;product_max_per_order : $this-&gt;element-&gt;main-&gt;product_max_per_order; if($this-&gt;row-&gt;product_quantity &gt; 0) $max_quantity = min($max_quantity, $this-&gt;row-&gt;product_quantity); $min_quantity = max((int)$min_quantity, 1); $max_quantity = max((int)$max_quantity, 0); } else { $min_quantity = max((int)$this-&gt;params-&gt;get('min_quantity', 0), 1); $max_quantity = max((int)$this-&gt;params-&gt;get('max_quantity', 0), 0); }

Etc....

Thanks!

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

Less More

- Posts: 86360
- Thank you received: 14296
-
-

9 years 1 month ago [\#278801](#278801) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Quantity Dropdown to Match Quantity of Product](/forum/25-install-update/891851-quantity-dropdown-to-match-quantity-of-product#278801 "-- HikaShop version -- : 3.1.1 -- Joomla version -- : 3.7.5  Is it possible to have the quantity dropdown display the amount of quantity available for that item?  Currently the dropdown is always showing 15. Example, if I have 3 bags, then it should only go up to 3, if I have 5 earrings then it only goes up to 5, etc...  Thanks!!")*

Hi,

This works fine on our end. Please provide a link to a product page with the issue and a backend access so that we can check your settings.
[ www.hikashop.com/support/contact-us.html](https://www.hikashop.com/support/contact-us.html)

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

Less More

- Posts: 86360
- Thank you received: 14296
-
-

9 years 1 month ago [\#278875](#278875) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Quantity Dropdown to Match Quantity of Product](/forum/25-install-update/891851-quantity-dropdown-to-match-quantity-of-product#278875 "-- HikaShop version -- : 3.1.1 -- Joomla version -- : 3.7.5  Is it possible to have the quantity dropdown display the amount of quantity available for that item?  Currently the dropdown is always showing 15. Example, if I have 3 bags, then it should only go up to 3, if I have 5 earrings then it only goes up to 5, etc...  Thanks!!")*

Hi,

Thanks for the access. I was able to find the issue. The code to use has to be a bit more complex: Code:

if($this-&gt;row-&gt;product_quantity &gt; 0) { if($max_quantity &gt; 0) $max_quantity = min($max_quantity, $this-&gt;row-&gt;product_quantity); else $max_quantity = $this-&gt;row-&gt;product_quantity; }

I've made the change for you and it seems to be working now. It will be integrated in the next version.

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

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

Less More

- Posts: 966
- Thank you received: 11
-
-

9 years 1 month ago [\#279167](#279167) by [MyWorld](/forum/user/862-myworld "View MyWorld's Profile")  Replied by *[MyWorld](/forum/user/862-myworld "View MyWorld's Profile")* on topic *[Quantity Dropdown to Match Quantity of Product](/forum/25-install-update/891851-quantity-dropdown-to-match-quantity-of-product#279167 "-- HikaShop version -- : 3.1.1 -- Joomla version -- : 3.7.5  Is it possible to have the quantity dropdown display the amount of quantity available for that item?  Currently the dropdown is always showing 15. Example, if I have 3 bags, then it should only go up to 3, if I have 5 earrings then it only goes up to 5, etc...  Thanks!!")*

Thank you for this. Really appreciate it!!

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

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