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

#   How to use custom fields to modify quantity field

##

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

Less More

- Posts: 11
- Thank you received: 0
-
-

15 years 1 week ago [\#29281](#29281) by [tjsan](/forum/user/4321-tjsan "View tjsan's Profile")  *[How to use custom fields to modify quantity field](/forum/4-how-to/29281-how-to-use-custom-fields-to-modify-quantity-field#29281 "Hi, I have just installed HS essentials and I am wondering if it is possible to alter the way that the product quantity input field behaves based on a custom field.  I have created a file in my template folder that overrides the default behaviour with a dropdown box containing options for fixed quantities of 50,100,150,200 ... and this works fine. But I would like to create a product custom field that defines what the incremental values would be.  If the value is for example,qty&#95;range = &quot;50;100;150;200&quot;, then the input would be a dropdown containing those values.  If the value is 0 or blank, it would default to a normal (ajax) input field.  Can I access the custom field from within the templates/TEMPLATE/html/hikashop&#95;button.php ?")* was created by *[tjsan](/forum/user/4321-tjsan "View tjsan's Profile")*

Hi, I have just installed HS essentials and I am wondering if it is possible to alter the way that the product quantity input field behaves based on a custom field.

I have created a file in my template folder that overrides the default behaviour with a dropdown box containing options for fixed quantities of 50,100,150,200 ... and this works fine. But I would like to create a product custom field that defines what the incremental values would be.

If the value is for example,qty_range = "50;100;150;200", then the input would be a dropdown containing those values.

If the value is 0 or blank, it would default to a normal (ajax) input field.

Can I access the custom field from within the templates/TEMPLATE/html/hikashop_button.php ?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5MjgxLWhvdy10by11c2UtY3VzdG9tLWZpZWxkcy10by1tb2RpZnktcXVhbnRpdHktZmllbGQ/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: 86570
- Thank you received: 14314
-
-

15 years 1 week ago [\#29308](#29308) 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 use custom fields to modify quantity field](/forum/4-how-to/29281-how-to-use-custom-fields-to-modify-quantity-field#29308 "Hi, I have just installed HS essentials and I am wondering if it is possible to alter the way that the product quantity input field behaves based on a custom field.  I have created a file in my template folder that overrides the default behaviour with a dropdown box containing options for fixed quantities of 50,100,150,200 ... and this works fine. But I would like to create a product custom field that defines what the incremental values would be.  If the value is for example,qty&#95;range = &quot;50;100;150;200&quot;, then the input would be a dropdown containing those values.  If the value is 0 or blank, it would default to a normal (ajax) input field.  Can I access the custom field from within the templates/TEMPLATE/html/hikashop&#95;button.php ?")*

If your quantity field is displayed on product pages (not on listings) then you can retrieve the custom field like that:

$productClass = hikashop_get('class.product');
$product = $productClass-&gt;get(JRequest::getInt('cid'));
echo $product-&gt;CUSTOM_FIELD_COLUMN_NAME;

where CUSTOM_FIELD_COLUMN_NAME is the column name of your custom field.

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

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

Less More

- Posts: 11
- Thank you received: 0
-
-

15 years 1 week ago [\#29313](#29313) by [tjsan](/forum/user/4321-tjsan "View tjsan's Profile")  Replied by *[tjsan](/forum/user/4321-tjsan "View tjsan's Profile")* on topic *[Re: How to use custom fields to modify quantity field](/forum/4-how-to/29281-how-to-use-custom-fields-to-modify-quantity-field#29313 "Hi, I have just installed HS essentials and I am wondering if it is possible to alter the way that the product quantity input field behaves based on a custom field.  I have created a file in my template folder that overrides the default behaviour with a dropdown box containing options for fixed quantities of 50,100,150,200 ... and this works fine. But I would like to create a product custom field that defines what the incremental values would be.  If the value is for example,qty&#95;range = &quot;50;100;150;200&quot;, then the input would be a dropdown containing those values.  If the value is 0 or blank, it would default to a normal (ajax) input field.  Can I access the custom field from within the templates/TEMPLATE/html/hikashop&#95;button.php ?")*

Thanks Nicolas - that works perfectly!

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

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

Less More

- Posts: 12
- Thank you received: 0
-
-

12 years 10 months ago -  12 years 10 months ago [\#139225](#139225) by [printco](/forum/user/15621-printco "View printco's Profile")  Replied by *[printco](/forum/user/15621-printco "View printco's Profile")* on topic *[Re: How to use custom fields to modify quantity field](/forum/4-how-to/29281-how-to-use-custom-fields-to-modify-quantity-field#139225 "Hi, I have just installed HS essentials and I am wondering if it is possible to alter the way that the product quantity input field behaves based on a custom field.  I have created a file in my template folder that overrides the default behaviour with a dropdown box containing options for fixed quantities of 50,100,150,200 ... and this works fine. But I would like to create a product custom field that defines what the incremental values would be.  If the value is for example,qty&#95;range = &quot;50;100;150;200&quot;, then the input would be a dropdown containing those values.  If the value is 0 or blank, it would default to a normal (ajax) input field.  Can I access the custom field from within the templates/TEMPLATE/html/hikashop&#95;button.php ?")*

> nicolas wrote: If your quantity field is displayed on product pages (not on listings) then you can retrieve the custom field like that:
>
> $productClass = hikashop\_get('class.product');
> $product = $productClass-&gt;get(JRequest::getInt('cid'));
> echo $product-&gt;CUSTOM\_FIELD\_COLUMN\_NAME;
>
> where CUSTOM\_FIELD\_COLUMN\_NAME is the column name of your custom field.

When you do it like this, does the system actually use the number from the custom field as if it was input in the normal input box? For instance, if I create a custom drop down with exact predetermined quantities, will it treat the value of the selected drop down (if it's a number) as normal (that way it will calculate the weight for shipping and the total cost and all that)? To put it in programmer terminology, will it populate the quantity field for the cart DB table with the value of the custom field (again, obviously only if the value of the custom field selection is a number or integer or whatever)?

Last edit: 12 years 10 months ago by [printco](/forum/user/15621-printco "View printco's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5MjgxLWhvdy10by11c2UtY3VzdG9tLWZpZWxkcy10by1tb2RpZnktcXVhbnRpdHktZmllbGQ/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: 86570
- Thank you received: 14314
-
-

12 years 10 months ago [\#139239](#139239) 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 use custom fields to modify quantity field](/forum/4-how-to/29281-how-to-use-custom-fields-to-modify-quantity-field#139239 "Hi, I have just installed HS essentials and I am wondering if it is possible to alter the way that the product quantity input field behaves based on a custom field.  I have created a file in my template folder that overrides the default behaviour with a dropdown box containing options for fixed quantities of 50,100,150,200 ... and this works fine. But I would like to create a product custom field that defines what the incremental values would be.  If the value is for example,qty&#95;range = &quot;50;100;150;200&quot;, then the input would be a dropdown containing those values.  If the value is 0 or blank, it would default to a normal (ajax) input field.  Can I access the custom field from within the templates/TEMPLATE/html/hikashop&#95;button.php ?")*

No it won't. If you want to replace the quantity box by a dropdown with predefined values, you should do it like that instead:
[ www.hikashop.com/forum/4-how-to/15254-re...uantity-ordered.html](http://www.hikashop.com/forum/4-how-to/15254-restricting-quantity-ordered.html)

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

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

Less More

- Posts: 12
- Thank you received: 0
-
-

12 years 10 months ago [\#139241](#139241) by [printco](/forum/user/15621-printco "View printco's Profile")  Replied by *[printco](/forum/user/15621-printco "View printco's Profile")* on topic *[Re: How to use custom fields to modify quantity field](/forum/4-how-to/29281-how-to-use-custom-fields-to-modify-quantity-field#139241 "Hi, I have just installed HS essentials and I am wondering if it is possible to alter the way that the product quantity input field behaves based on a custom field.  I have created a file in my template folder that overrides the default behaviour with a dropdown box containing options for fixed quantities of 50,100,150,200 ... and this works fine. But I would like to create a product custom field that defines what the incremental values would be.  If the value is for example,qty&#95;range = &quot;50;100;150;200&quot;, then the input would be a dropdown containing those values.  If the value is 0 or blank, it would default to a normal (ajax) input field.  Can I access the custom field from within the templates/TEMPLATE/html/hikashop&#95;button.php ?")*

I don't want this to be a global change. We are selling different items at different preset quantities. What WOULD be helpful is if we could set up a custom field to do this for us (that way I can set up multiple custom fields with the different preset quantities), or if we could assign the different dropdown preset quantities based on categories or something along those lines.

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

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

Less More

- Posts: 12
- Thank you received: 0
-
-

12 years 10 months ago [\#139245](#139245) by [printco](/forum/user/15621-printco "View printco's Profile")  Replied by *[printco](/forum/user/15621-printco "View printco's Profile")* on topic *[Re: How to use custom fields to modify quantity field](/forum/4-how-to/29281-how-to-use-custom-fields-to-modify-quantity-field#139245 "Hi, I have just installed HS essentials and I am wondering if it is possible to alter the way that the product quantity input field behaves based on a custom field.  I have created a file in my template folder that overrides the default behaviour with a dropdown box containing options for fixed quantities of 50,100,150,200 ... and this works fine. But I would like to create a product custom field that defines what the incremental values would be.  If the value is for example,qty&#95;range = &quot;50;100;150;200&quot;, then the input would be a dropdown containing those values.  If the value is 0 or blank, it would default to a normal (ajax) input field.  Can I access the custom field from within the templates/TEMPLATE/html/hikashop&#95;button.php ?")*

> nicolas wrote: If your quantity field is displayed on product pages (not on listings) then you can retrieve the custom field like that:
>
> $productClass = hikashop\_get('class.product');
> $product = $productClass-&gt;get(JRequest::getInt('cid'));
> echo $product-&gt;CUSTOM\_FIELD\_COLUMN\_NAME;
>
> where CUSTOM\_FIELD\_COLUMN\_NAME is the column name of your custom field.

It seems to me like you should only have to add on like one more line of code on to this ^^^ code to tell it to retrieve the value for the selected drop down choice and assign it to the quantity variable -&gt; then add that value to the quantity column in the DB when you click on the button.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI5MjgxLWhvdy10by11c2UtY3VzdG9tLWZpZWxkcy10by1tb2RpZnktcXVhbnRpdHktZmllbGQ/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: 86570
- Thank you received: 14314
-
-

12 years 10 months ago [\#139340](#139340) 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 use custom fields to modify quantity field](/forum/4-how-to/29281-how-to-use-custom-fields-to-modify-quantity-field#139340 "Hi, I have just installed HS essentials and I am wondering if it is possible to alter the way that the product quantity input field behaves based on a custom field.  I have created a file in my template folder that overrides the default behaviour with a dropdown box containing options for fixed quantities of 50,100,150,200 ... and this works fine. But I would like to create a product custom field that defines what the incremental values would be.  If the value is for example,qty&#95;range = &quot;50;100;150;200&quot;, then the input would be a dropdown containing those values.  If the value is 0 or blank, it would default to a normal (ajax) input field.  Can I access the custom field from within the templates/TEMPLATE/html/hikashop&#95;button.php ?")*

You can do that with a product quantity override plugin:
[ www.hikashop.com/support/support/documen...tation.html#override](http://www.hikashop.com/support/support/documentation/62-hikashop-developer-documentation.html#override)
You can see an example of such plugin here:
[ demo.hikashop.com/index.php?option=com\_h...ct&amp;task=show&amp;cid=214](http://demo.hikashop.com/index.php?option=com_hikashop&ctrl=product&task=show&cid=214)

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

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