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

#   \[Solved\] Product multiple "minimum quantity"

##

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

Less More

- Posts: 101
- Thank you received: 12
-
-

13 years 8 months ago -  13 years 8 months ago [\#90314](#90314) by [SG](/forum/user/12204-sg "View SG's Profile")  *[\[Solved\] Product multiple "minimum quantity"](/forum/4-how-to/78412-solved-product-multiple-minimum-quantity#90314 "Hi,  Let's say we have a product called PENCIL RAINBOW and the &quot;product min per order&quot; is 20. What we'd like to achieve is that when you change the quantity that only the multiples of 2O are possible like 20, 40, 60, 80 and so on. 21 for instance is not allowed.  Is there to do this and perhaps show a message like:  Thanks,  SG  subscription: HikaShop Business")* was created by *[SG](/forum/user/12204-sg "View SG's Profile")*

Hi,

Let's say we have a product called PENCIL RAINBOW and the "product min per order" is 20.
What we'd like to achieve is that when you change the quantity that only the multiples of 2O are possible like 20, 40, 60, 80 and so on.
21 for instance is not allowed.

Is there to do this and perhaps show a message like:
PENCIL RAINBOW Quantity has to be divisible by the minimum quantity: 20

Thanks,

SG

subscription: HikaShop Business

Last edit: 13 years 8 months ago by [SG](/forum/user/12204-sg "View SG's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzc4NDEyLXNvbHZlZC1wcm9kdWN0LW11bHRpcGxlLXFtaW5pbXVtLXF1YW50aXR5cT90bXBsPW1hcmtkb3du) 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: 86320
- Thank you received: 14279
-
-

13 years 8 months ago [\#90515](#90515) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Product min per order](/forum/4-how-to/78412-solved-product-multiple-minimum-quantity#90515 "Hi,  Let's say we have a product called PENCIL RAINBOW and the &quot;product min per order&quot; is 20. What we'd like to achieve is that when you change the quantity that only the multiples of 2O are possible like 20, 40, 60, 80 and so on. 21 for instance is not allowed.  Is there to do this and perhaps show a message like:  Thanks,  SG  subscription: HikaShop Business")*

Hi,

You can use a quantity field override in your template to change the input field for the quantity into a dropdown.
We have some documentation about that here:
[ www.hikashop.com/en/support/documentatio...tation.html#override](http://www.hikashop.com/en/support/documentation/62-hikashop-developer-documentation.html#override)
and an example here: Code:

&lt;?php function hikashop_quantity_render($html,$i,$max_quantity,$min_quantity){ return '&lt;select name="quantity"&gt;&lt;option value="20"&gt;20&lt;/option&gt;&lt;option value="40"&gt;40&lt;/option&gt;&lt;/select&gt;'.$html; }

The following user(s) said Thank You: [SG](/forum/user/12204-sg "View SG's Profile")

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

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

Less More

- Posts: 101
- Thank you received: 12
-
-

13 years 8 months ago [\#90683](#90683) by [SG](/forum/user/12204-sg "View SG's Profile")  Replied by *[SG](/forum/user/12204-sg "View SG's Profile")* on topic *[Product min per order](/forum/4-how-to/78412-solved-product-multiple-minimum-quantity#90683 "Hi,  Let's say we have a product called PENCIL RAINBOW and the &quot;product min per order&quot; is 20. What we'd like to achieve is that when you change the quantity that only the multiples of 2O are possible like 20, 40, 60, 80 and so on. 21 for instance is not allowed.  Is there to do this and perhaps show a message like:  Thanks,  SG  subscription: HikaShop Business")*

Hi,

At first I didn't think to use dropdown but just use a textfield and show a message when someone fills in something wrong.
But with the dropdown it works.

Here you can see it with 20 times the min quantity. So a dropdown with 20 numbers is shown.
And it's dynamic in the way that it uses the $min_quantity so it can be used for all products.
Code:

&lt;?php function hikashop_quantity_render($html,$i,$max_quantity,$min_quantity){ $ret1 = '&lt;select id="hikashop_product_quantity_field_'.$i.'" name="quantity"&gt;'; $ret2 = ""; $jmax = $min_quantity*10; for($j=1; $j&lt;=20; $j++) { $multiple_min_quantity = $min_quantity * $j; $ret2= $ret2 . '&lt;option value="'.$multiple_min_quantity.'"&gt;'.$multiple_min_quantity.'&lt;/option&gt;'; } return $ret1 . $ret2 . '&lt;/select&gt;'.$html; }

Thanks for helping me get there.

**How could I do this for the checkout?
Can I use similar code some where?**

Greets.

SG

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

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

13 years 8 months ago [\#90812](#90812) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Product min per order](/forum/4-how-to/78412-solved-product-multiple-minimum-quantity#90812 "Hi,  Let's say we have a product called PENCIL RAINBOW and the &quot;product min per order&quot; is 20. What we'd like to achieve is that when you change the quantity that only the multiples of 2O are possible like 20, 40, 60, 80 and so on. 21 for instance is not allowed.  Is there to do this and perhaps show a message like:  Thanks,  SG  subscription: HikaShop Business")*

Hi,

For the checkout, you can edit the view "checkout / cart" and use the previous code, you should just have to change the variables called.

The following user(s) said Thank You: [SG](/forum/user/12204-sg "View SG's Profile")

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

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

Less More

- Posts: 101
- Thank you received: 12
-
-

13 years 8 months ago -  13 years 8 months ago [\#90901](#90901) by [SG](/forum/user/12204-sg "View SG's Profile")  Replied by *[SG](/forum/user/12204-sg "View SG's Profile")* on topic *[Product min per order](/forum/4-how-to/78412-solved-product-multiple-minimum-quantity#90901 "Hi,  Let's say we have a product called PENCIL RAINBOW and the &quot;product min per order&quot; is 20. What we'd like to achieve is that when you change the quantity that only the multiples of 2O are possible like 20, 40, 60, 80 and so on. 21 for instance is not allowed.  Is there to do this and perhaps show a message like:  Thanks,  SG  subscription: HikaShop Business")*

Hi,

Thank you for your reply, which helped a lot. (I do have some questions below)

This is the result that I came up with.
Maybe it can still be made easier, so anyone feel free to make it cleaner and shorter. (I don't mind)
Oh yes, I added a if-statement to be able to select(selected="selected") the right value ($row-&gt;cart_product_quantity).
Code:

&lt;select id="hikashop_checkout_quantity_&lt;?php echo $row-&gt;cart_product_id; ?&gt;" name="item[&lt;?php echo $row-&gt;cart_product_id;?&gt;]" class="hikashop_product_quantity_field_dropdown"&gt; &lt;?php $min_quantity = $row-&gt;product_min_per_order; $cart_product_quantity = $row-&gt;cart_product_quantity; $jmax = $min_quantity*10; for($j=1; $j&lt;=20; $j++) { $multiple_min_quantity = $min_quantity * $j; if ($multiple_min_quantity == $cart_product_quantity) { ?&gt; &lt;option value="&lt;?php echo $multiple_min_quantity; ?&gt;" selected="selected" onchange="var qty_field = document.getElementById('hikashop_checkout_quantity_&lt;?php echo $row-&gt;cart_product_id;?&gt;'); if (qty_field){&lt;?php echo $input; ?&gt;}"&gt; &lt;?php echo $multiple_min_quantity; ?&gt;&lt;/option&gt; &lt;?php } else { ?&gt; &lt;option value="&lt;?php echo $multiple_min_quantity; ?&gt;" onchange="var qty_field = document.getElementById('hikashop_checkout_quantity_&lt;?php echo $row-&gt;cart_product_id;?&gt;'); if (qty_field){&lt;?php echo $input; ?&gt;}"&gt; &lt;?php echo $multiple_min_quantity; ?&gt;&lt;/option&gt; &lt;?php } } ?&gt; &lt;/select&gt;

I changed the class name of the select into **.hikashop\_product\_quantity\_field\_dropdown** and added the following in the **frontend\_custom.css**Code:

.hikashop_product_quantity_field_dropdown{ float:left; }

**Some related questions:**

1) Does the onchange in the option value do something. I'm not sure what $input is used for and what is happening.
Can you elaborate in what this does and whether it makes a difference if it's there or not?
I mean this code: Code:

onchange="var qty_field = document.getElementById('hikashop_checkout_quantity_&lt;?php echo $row-&gt;cart_product_id;?&gt;'); if (qty_field){&lt;?php echo $input; ?&gt;}"

2) STANGE BEHAVIOUR: I didn't change anything in the delete button but when I click on it, it jumps step 2.
This is the code which I didn't touch:
Code:

&lt;?php if($this-&gt;params-&gt;get('show_delete',1)){ ?&gt; &lt;div class="hikashop_cart_product_quantity_delete"&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;'); if(qty_field){qty_field.value=0; &lt;?php echo $input; ?&gt; qty_field.form.submit();} return false;" title="&lt;?php echo JText::_('HIKA_DELETE'); ?&gt;"&gt; &lt;img src="&lt;?php echo HIKASHOP_IMAGES . 'delete2.png';?&gt;" border="0" alt="&lt;?php echo JText::_('HIKA_DELETE'); ?&gt;" /&gt; &lt;/a&gt; &lt;/div&gt; &lt;?php } ?&gt;

Thanks

Last edit: 13 years 8 months ago by [SG](/forum/user/12204-sg "View SG's Profile"). Reason: removed the 3rd question

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzc4NDEyLXNvbHZlZC1wcm9kdWN0LW11bHRpcGxlLXFtaW5pbXVtLXF1YW50aXR5cT90bXBsPW1hcmtkb3du) 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: 86320
- Thank you received: 14279
-
-

13 years 8 months ago [\#91107](#91107) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Product min per order](/forum/4-how-to/78412-solved-product-multiple-minimum-quantity#91107 "Hi,  Let's say we have a product called PENCIL RAINBOW and the &quot;product min per order&quot; is 20. What we'd like to achieve is that when you change the quantity that only the multiples of 2O are possible like 20, 40, 60, 80 and so on. 21 for instance is not allowed.  Is there to do this and perhaps show a message like:  Thanks,  SG  subscription: HikaShop Business")*

1. It doesn't do anything so you don't need to have it on the checkout cart. It's used for other quantity fields like the ones on products listings, on the product page...

2. The piece $this-&gt;params-&gt;get('url') on that code should be the current URL of the page ( so that the system redirects back to the current page once the product is removed ). Isn't that the case ? If not, as a quick fix, you can directly put the URL of the step with the cart in there and that should help it stay on the current step.

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

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

Less More

- Posts: 101
- Thank you received: 12
-
-

13 years 8 months ago -  13 years 8 months ago [\#91188](#91188) by [SG](/forum/user/12204-sg "View SG's Profile")  Replied by *[SG](/forum/user/12204-sg "View SG's Profile")* on topic *[Product min per order](/forum/4-how-to/78412-solved-product-multiple-minimum-quantity#91188 "Hi,  Let's say we have a product called PENCIL RAINBOW and the &quot;product min per order&quot; is 20. What we'd like to achieve is that when you change the quantity that only the multiples of 2O are possible like 20, 40, 60, 80 and so on. 21 for instance is not allowed.  Is there to do this and perhaps show a message like:  Thanks,  SG  subscription: HikaShop Business")*

Hi,

About Question 2:
I forgot to say something important.
It's not that it just jumps to the next page.
It's that it doesn't delete the product and just jumps to the next page.

(Sorry I forgot the important part about that it doesn't delete the product :blush: )

I think it has to do with the following code but I might be wrong:
Code:

onclick="var qty_field = document.getElementById('hikashop_checkout_quantity_&lt;?php echo $row-&gt;cart_product_id;?&gt;'); if(qty_field){qty_field.value=0; &lt;?php echo $input; ?&gt; qty_field.form.submit();} return false;" title="&lt;?php echo JText::_('HIKA_DELETE'); ?&gt;"&gt;

So somehow because I changed the input into a select field (dropdown) the delete button doesn't work.

**I really can't figure out why the product is not deleted and just jumps to the second page.**

EDIT:
I searched further and I found this post:
[ ](http://www.hikashop.com/en/forum/4-how-to/77189-delete-item-in-cart-is-linked-to-register-page.html#84540)[ www.hikashop.com/en/forum/4-how-to/77189...ster-page.html#84540](http://www.hikashop.com/en/forum/4-how-to/77189-delete-item-in-cart-is-linked-to-register-page.html#84540)
Here Xavier says the following to the person:

> The problem is that you have customize the quantity input for a product, but the value 0 is missing, so the script take the first value which is 5, that's why the product is not removed in the cart.

So I think I have the same problem. But how can I resolve it?

Thanks

Last edit: 13 years 8 months ago by [SG](/forum/user/12204-sg "View SG's Profile"). Reason: Added an EDIT part

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

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

Less More

- Posts: 101
- Thank you received: 12
-
-

13 years 8 months ago [\#91191](#91191) by [SG](/forum/user/12204-sg "View SG's Profile")  Replied by *[SG](/forum/user/12204-sg "View SG's Profile")* on topic *[Product min per order](/forum/4-how-to/78412-solved-product-multiple-minimum-quantity#91191 "Hi,  Let's say we have a product called PENCIL RAINBOW and the &quot;product min per order&quot; is 20. What we'd like to achieve is that when you change the quantity that only the multiples of 2O are possible like 20, 40, 60, 80 and so on. 21 for instance is not allowed.  Is there to do this and perhaps show a message like:  Thanks,  SG  subscription: HikaShop Business")*

Hi,

Ok I think I got a simple solution ![:)](/media/kunena/emoticons/3.png ":)")

I've just added the following: Code:

&lt;option value="0"&gt;0&lt;/option&gt;

Now it works and deletes the product.

So if understand correctly it wasn't working because qty_field.value=0; couldn't be excuted because there was no 0 value in de dropdownlist.
Did the code then stop and didn't execute &lt;?php echo $input; ?&gt; qty_field.form.submit();}

I'm trying to understand what happened before without the 0.
And what does the echo $input; do here?

Thanks

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzc4NDEyLXNvbHZlZC1wcm9kdWN0LW11bHRpcGxlLXFtaW5pbXVtLXF1YW50aXR5cT90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

13 years 8 months ago [\#91290](#91290) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Product min per order](/forum/4-how-to/78412-solved-product-multiple-minimum-quantity#91290 "Hi,  Let's say we have a product called PENCIL RAINBOW and the &quot;product min per order&quot; is 20. What we'd like to achieve is that when you change the quantity that only the multiples of 2O are possible like 20, 40, 60, 80 and so on. 21 for instance is not allowed.  Is there to do this and perhaps show a message like:  Thanks,  SG  subscription: HikaShop Business")*

Hi,

Right !

If your dropdown does not contains "0", it is not possible for the javascript to select the "0" value into.
So, it does not change the value of the list and it submit the exact same cart with the same quantities.

Regards,

---

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

The following user(s) said Thank You: [SG](/forum/user/12204-sg "View SG's Profile")

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

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

[](#top)
