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

#   Allow fractional quantity

##

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

Less More

- Posts: 1
- Thank you received: 0
-
-

15 years 2 months ago [\#24005](#24005) by [one320b](/forum/user/3738-one320b "View one320b's Profile")  *[Allow fractional quantity](/forum/4-how-to/24005-allow-fractional-quantity#24005 "Let me preface by stating, I already know this is a difficult task. I've reviewed much of the code already and I'm not concerned with payment services not understanding fractional quantities.  That being said, how would one about making this change? I see that the quantity is stored as an INT in the database, and that everywhere I've seen it in code its being cast as an INT (IE: $quantity=(int)$quantity). I went in and attempted to cast the variables for quantity as a FLOAT datatype, and changed the DB datatype to FLOAT as well. I must be missing something though as it continues to round out my quantities once added to the cart.  Can you by any chance break down the process and files touched when a user clicks on &quot;add to cart&quot;? I think I'm just missing a file or variable somewhere and can't figure out where.  I would be glad to offer my code to everyone looking for this functionality in exchange once I get it working :)  Side note, Hikashop should really look at making this an option in future versions. Most commercial and some open source (ZenCart) products already do this. However, none of them in my opinion are is easy to work with within Joomla!  Thanks!")* was created by *[one320b](/forum/user/3738-one320b "View one320b's Profile")*

Let me preface by stating, I already know this is a difficult task. I've reviewed much of the code already and I'm not concerned with payment services not understanding fractional quantities.

That being said, how would one about making this change? I see that the quantity is stored as an INT in the database, and that everywhere I've seen it in code its being cast as an INT (IE: $quantity=(int)$quantity). I went in and attempted to cast the variables for quantity as a FLOAT datatype, and changed the DB datatype to FLOAT as well. I must be missing something though as it continues to round out my quantities once added to the cart.

Can you by any chance break down the process and files touched when a user clicks on "add to cart"? I think I'm just missing a file or variable somewhere and can't figure out where.

I would be glad to offer my code to everyone looking for this functionality in exchange once I get it working ![:)](/media/kunena/emoticons/8.png ":)")

Side note, Hikashop should really look at making this an option in future versions. Most commercial and some open source (ZenCart) products already do this. However, none of them in my opinion are is easy to work with within Joomla!

Thanks!

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

Less More

- Posts: 86290
- Thank you received: 14268
-
-

15 years 2 months ago [\#24006](#24006) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Allow fractional quantity](/forum/4-how-to/24005-allow-fractional-quantity#24006 "Let me preface by stating, I already know this is a difficult task. I've reviewed much of the code already and I'm not concerned with payment services not understanding fractional quantities.  That being said, how would one about making this change? I see that the quantity is stored as an INT in the database, and that everywhere I've seen it in code its being cast as an INT (IE: $quantity=(int)$quantity). I went in and attempted to cast the variables for quantity as a FLOAT datatype, and changed the DB datatype to FLOAT as well. I must be missing something though as it continues to round out my quantities once added to the cart.  Can you by any chance break down the process and files touched when a user clicks on &quot;add to cart&quot;? I think I'm just missing a file or variable somewhere and can't figure out where.  I would be glad to offer my code to everyone looking for this functionality in exchange once I get it working :)  Side note, Hikashop should really look at making this an option in future versions. Most commercial and some open source (ZenCart) products already do this. However, none of them in my opinion are is easy to work with within Joomla!  Thanks!")*

The solution is actually more simple than trying to modify the code everywhere you have quantities work with fractions.

You should create a custom field of the table "item" (only in the Business edition) and of the type "text" published and activated on the front end which will act as the fractional quantity.
Then, you can create a small price quantity calculation override plugin to specify how you want the quantities to be calculated. We have some documentation on there there: [ www.hikashop.com/support/documentation/6...tation.html#override](http://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#override)
Finally, you can hide the quantity input with CSS if you want.

It's a bit more complicated than just turning on an option as you need to code the plugin (it's around 20 lines top), but it allows way more flexibility as that enables you to calculate complex quantities like prices per weight unit, or per length, or per m², or based on the number of letters the user enters in the input text, etc and even have several different ways of calculating prices based on different custom fields, for different products on your store as you have the whole custom field flexibility.

Also, by doing a plugin, you won't have any problem updating HikaShop as you won't need to change any core files of HikaShop.

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

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

Less More

- Posts: 27
- Thank you received: 1
-
-

13 years 6 months ago [\#100557](#100557) by [mancer](/forum/user/16783-mancer "View mancer's Profile")  Replied by *[mancer](/forum/user/16783-mancer "View mancer's Profile")* on topic *[Re: Allow fractional quantity](/forum/4-how-to/24005-allow-fractional-quantity#100557 "Let me preface by stating, I already know this is a difficult task. I've reviewed much of the code already and I'm not concerned with payment services not understanding fractional quantities.  That being said, how would one about making this change? I see that the quantity is stored as an INT in the database, and that everywhere I've seen it in code its being cast as an INT (IE: $quantity=(int)$quantity). I went in and attempted to cast the variables for quantity as a FLOAT datatype, and changed the DB datatype to FLOAT as well. I must be missing something though as it continues to round out my quantities once added to the cart.  Can you by any chance break down the process and files touched when a user clicks on &quot;add to cart&quot;? I think I'm just missing a file or variable somewhere and can't figure out where.  I would be glad to offer my code to everyone looking for this functionality in exchange once I get it working :)  Side note, Hikashop should really look at making this an option in future versions. Most commercial and some open source (ZenCart) products already do this. However, none of them in my opinion are is easy to work with within Joomla!  Thanks!")*

I too require this functionality... as a new user of HS would find this quite daunting. As this posting is almost 2 years old, has there been any updates or further developments on this?

I have many shopfronts to construct (many are material suppliers in the construction industry) where this is imperative.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI0MDA1LWFsbG93LWZyYWN0aW9uYWwtcXVhbnRpdHk/dG1wbD1tYXJrZG93bg==) 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 6 months ago [\#100742](#100742) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Re: Allow fractional quantity](/forum/4-how-to/24005-allow-fractional-quantity#100742 "Let me preface by stating, I already know this is a difficult task. I've reviewed much of the code already and I'm not concerned with payment services not understanding fractional quantities.  That being said, how would one about making this change? I see that the quantity is stored as an INT in the database, and that everywhere I've seen it in code its being cast as an INT (IE: $quantity=(int)$quantity). I went in and attempted to cast the variables for quantity as a FLOAT datatype, and changed the DB datatype to FLOAT as well. I must be missing something though as it continues to round out my quantities once added to the cart.  Can you by any chance break down the process and files touched when a user clicks on &quot;add to cart&quot;? I think I'm just missing a file or variable somewhere and can't figure out where.  I would be glad to offer my code to everyone looking for this functionality in exchange once I get it working :)  Side note, Hikashop should really look at making this an option in future versions. Most commercial and some open source (ZenCart) products already do this. However, none of them in my opinion are is easy to work with within Joomla!  Thanks!")*

Hi,

We are currently developing a new feature which will allow you to do anything on anything, you will be able to change the values on some item as a mass action.
With this, it will be possible to make operations to change quantities, prices, etc. For example, use the current quantity and add anything on it depending on what you want.
And fractions will be authorized.

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

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

Less More

- Posts: 27
- Thank you received: 1
-
-

13 years 6 months ago [\#100744](#100744) by [mancer](/forum/user/16783-mancer "View mancer's Profile")  Replied by *[mancer](/forum/user/16783-mancer "View mancer's Profile")* on topic *[Re: Allow fractional quantity](/forum/4-how-to/24005-allow-fractional-quantity#100744 "Let me preface by stating, I already know this is a difficult task. I've reviewed much of the code already and I'm not concerned with payment services not understanding fractional quantities.  That being said, how would one about making this change? I see that the quantity is stored as an INT in the database, and that everywhere I've seen it in code its being cast as an INT (IE: $quantity=(int)$quantity). I went in and attempted to cast the variables for quantity as a FLOAT datatype, and changed the DB datatype to FLOAT as well. I must be missing something though as it continues to round out my quantities once added to the cart.  Can you by any chance break down the process and files touched when a user clicks on &quot;add to cart&quot;? I think I'm just missing a file or variable somewhere and can't figure out where.  I would be glad to offer my code to everyone looking for this functionality in exchange once I get it working :)  Side note, Hikashop should really look at making this an option in future versions. Most commercial and some open source (ZenCart) products already do this. However, none of them in my opinion are is easy to work with within Joomla!  Thanks!")*

okay.... but when do you think this will become available?? I need to commence building these shopfronts now.

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

Less More

- Posts: 86290
- Thank you received: 14268
-
-

13 years 6 months ago [\#100832](#100832) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Allow fractional quantity](/forum/4-how-to/24005-allow-fractional-quantity#100832 "Let me preface by stating, I already know this is a difficult task. I've reviewed much of the code already and I'm not concerned with payment services not understanding fractional quantities.  That being said, how would one about making this change? I see that the quantity is stored as an INT in the database, and that everywhere I've seen it in code its being cast as an INT (IE: $quantity=(int)$quantity). I went in and attempted to cast the variables for quantity as a FLOAT datatype, and changed the DB datatype to FLOAT as well. I must be missing something though as it continues to round out my quantities once added to the cart.  Can you by any chance break down the process and files touched when a user clicks on &quot;add to cart&quot;? I think I'm just missing a file or variable somewhere and can't figure out where.  I would be glad to offer my code to everyone looking for this functionality in exchange once I get it working :)  Side note, Hikashop should really look at making this an option in future versions. Most commercial and some open source (ZenCart) products already do this. However, none of them in my opinion are is easy to work with within Joomla!  Thanks!")*

Xavier didn't understand your question. The mass action feature that we're working on will allow you to modify the stock of the products in the backend.
It has no relation with the quantity the customers can input on the product page.

The solution I posted 2 years ago is still the same. And you have to have a plugin to calculate the price in the cart based on the value entered by the user in the product page. Fortunately, since then, we posted such plugin that you can find here:
[ www.hikashop.com/en/forum/2-general-talk...w-feature.html#24390](http://www.hikashop.com/en/forum/2-general-talk-about-hikashop/24377-new-feature.html#24390)
So all you have to do is to install that plugin and create a custom item field with the column name "ordered_weight" and your users will be able to enter their fractional quantity in that custom field and the calculation will be done automatically by the plugin based on the unit price of the product.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzI0MDA1LWFsbG93LWZyYWN0aW9uYWwtcXVhbnRpdHk/dG1wbD1tYXJrZG93bg==) 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)
-

9 years 4 months ago [\#270426](#270426) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Re: Allow fractional quantity](/forum/4-how-to/24005-allow-fractional-quantity#270426 "Let me preface by stating, I already know this is a difficult task. I've reviewed much of the code already and I'm not concerned with payment services not understanding fractional quantities.  That being said, how would one about making this change? I see that the quantity is stored as an INT in the database, and that everywhere I've seen it in code its being cast as an INT (IE: $quantity=(int)$quantity). I went in and attempted to cast the variables for quantity as a FLOAT datatype, and changed the DB datatype to FLOAT as well. I must be missing something though as it continues to round out my quantities once added to the cart.  Can you by any chance break down the process and files touched when a user clicks on &quot;add to cart&quot;? I think I'm just missing a file or variable somewhere and can't figure out where.  I would be glad to offer my code to everyone looking for this functionality in exchange once I get it working :)  Side note, Hikashop should really look at making this an option in future versions. Most commercial and some open source (ZenCart) products already do this. However, none of them in my opinion are is easy to work with within Joomla!  Thanks!")*

Hello

See :
[ www.hikashop.com/forum/2-general-talk-ab...w-feature.html#24390](https://www.hikashop.com/forum/2-general-talk-about-hikashop/24377-new-feature.html#24390)

---

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

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

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

[](#top)
