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

#   Decimal in Product Quantity (inventory/stock)

##

- **[3by400](/forum/user/6842-3by400 "View 3by400's Profile")**
- [![3by400's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6842.jpg)](/forum/user/6842-3by400 "View 3by400's Profile") Topic Author
- [ Offline](/forum/user/6842-3by400)

Less More

- Posts: 211
- Thank you received: 14
-
-
- [](https://3by400.com)
-

1 year 11 months ago [\#364919](#364919) by [3by400](/forum/user/6842-3by400 "View 3by400's Profile")  *[Decimal in Product Quantity (inventory/stock)](/forum/26-product-category-display/908961-decimal-in-product-quantity-inventory-stock#364919 "-- HikaShop version -- : 5.1.2 -- Joomla version -- : 5.2.2 -- PHP version -- : 8.2.14 -- Browser(s) name and version -- : n/a -- Error-message(debug-mod must be tuned on) -- : n/a  My client sells flooring - carpet, hardwood, etc - by the square foot. I've installed the Custom Quantity plugin to allow a customer to purchase a quantity with a decimal, but is there a way for me to set an inventory quantity in the product to include a decimal? And, then to maintain the remaining inventory to the decimal when the client purchases to the decimal?")* was created by *[3by400](/forum/user/6842-3by400 "View 3by400's Profile")*

-- HikaShop version -- : 5.1.2
-- Joomla version -- : 5.2.2
-- PHP version -- : 8.2.14
-- Browser(s) name and version -- : n/a
-- Error-message(debug-mod must be tuned on) -- : n/a

My client sells flooring - carpet, hardwood, etc - by the square foot. I've installed the Custom Quantity plugin to allow a customer to purchase a quantity with a decimal, but is there a way for me to set an inventory quantity in the product to include a decimal? And, then to maintain the remaining inventory to the decimal when the client purchases to the decimal?

---

3by400, Inc.
[ 3by400.com](https://3by400.com)
Websites that Work, Marketing that Matters

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

1 year 11 months ago [\#364922](#364922) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Decimal in Product Quantity (inventory/stock)](/forum/26-product-category-display/908961-decimal-in-product-quantity-inventory-stock#364922 "-- HikaShop version -- : 5.1.2 -- Joomla version -- : 5.2.2 -- PHP version -- : 8.2.14 -- Browser(s) name and version -- : n/a -- Error-message(debug-mod must be tuned on) -- : n/a  My client sells flooring - carpet, hardwood, etc - by the square foot. I've installed the Custom Quantity plugin to allow a customer to purchase a quantity with a decimal, but is there a way for me to set an inventory quantity in the product to include a decimal? And, then to maintain the remaining inventory to the decimal when the client purchases to the decimal?")*

Hi,

The inventory quantity can only be an integer, so no decimals.
I'm afraid you won't be able to do what you want.

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

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

Less More

- Posts: 1195
- Thank you received: 13
-
-

1 year 7 months ago [\#366311](#366311) by [verzevoul](/forum/user/8351-verzevoul "View verzevoul's Profile")  Replied by *[verzevoul](/forum/user/8351-verzevoul "View verzevoul's Profile")* on topic *[Decimal in Product Quantity (inventory/stock)](/forum/26-product-category-display/908961-decimal-in-product-quantity-inventory-stock#366311 "-- HikaShop version -- : 5.1.2 -- Joomla version -- : 5.2.2 -- PHP version -- : 8.2.14 -- Browser(s) name and version -- : n/a -- Error-message(debug-mod must be tuned on) -- : n/a  My client sells flooring - carpet, hardwood, etc - by the square foot. I've installed the Custom Quantity plugin to allow a customer to purchase a quantity with a decimal, but is there a way for me to set an inventory quantity in the product to include a decimal? And, then to maintain the remaining inventory to the decimal when the client purchases to the decimal?")*

Hi,
On behalf of our client we run a daily csv import of product quantities from his ERP.
The client uses decimal quantities and as the stock quantities on hikashop are a whole number, the client asks us to implement a floor function.
What would be the quickest way to do this? Which file would we need to modify etc?
Thank you!

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

1 year 7 months ago [\#366313](#366313) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Decimal in Product Quantity (inventory/stock)](/forum/26-product-category-display/908961-decimal-in-product-quantity-inventory-stock#366313 "-- HikaShop version -- : 5.1.2 -- Joomla version -- : 5.2.2 -- PHP version -- : 8.2.14 -- Browser(s) name and version -- : n/a -- Error-message(debug-mod must be tuned on) -- : n/a  My client sells flooring - carpet, hardwood, etc - by the square foot. I've installed the Custom Quantity plugin to allow a customer to purchase a quantity with a decimal, but is there a way for me to set an inventory quantity in the product to include a decimal? And, then to maintain the remaining inventory to the decimal when the client purchases to the decimal?")*

Hi,

Supposing that you're using the auto update products cron plugin for the import, before the line: Code:

foreach($this-&gt;fields as $field){

in the file administrator/components/com_hikashop/helpers/import.php, you could add: Code:

if(isset($product-&gt;product_quantity)) $product-&gt;product_quantity = (int)floor($product-&gt;product_quantity);

Ideally, instead of modifying the core file of HikaShop, you would create an override as per [ www.hikashop.com/support/documentation/6...ntation.html#classes](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#classes)
That way, you wouldn't have to redo the change after each update of HikaShop.

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

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

Less More

- Posts: 1195
- Thank you received: 13
-
-

1 year 6 months ago [\#366689](#366689) by [verzevoul](/forum/user/8351-verzevoul "View verzevoul's Profile")  Replied by *[verzevoul](/forum/user/8351-verzevoul "View verzevoul's Profile")* on topic *[Decimal in Product Quantity (inventory/stock)](/forum/26-product-category-display/908961-decimal-in-product-quantity-inventory-stock#366689 "-- HikaShop version -- : 5.1.2 -- Joomla version -- : 5.2.2 -- PHP version -- : 8.2.14 -- Browser(s) name and version -- : n/a -- Error-message(debug-mod must be tuned on) -- : n/a  My client sells flooring - carpet, hardwood, etc - by the square foot. I've installed the Custom Quantity plugin to allow a customer to purchase a quantity with a decimal, but is there a way for me to set an inventory quantity in the product to include a decimal? And, then to maintain the remaining inventory to the decimal when the client purchases to the decimal?")*

Hi, Nicolas.
Following up on the topic, a good client of ours has expressed a strong interest in having decimal quantities for his eshop products for both backend stock and frontend order placement.
We would like to find a solution so that he can continue to use Joomla.
Would it be possible with a plugin to meet his requirements and how many hikashop files would they need to be changed?
Thank you!

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

1 year 6 months ago [\#366694](#366694) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Decimal in Product Quantity (inventory/stock)](/forum/26-product-category-display/908961-decimal-in-product-quantity-inventory-stock#366694 "-- HikaShop version -- : 5.1.2 -- Joomla version -- : 5.2.2 -- PHP version -- : 8.2.14 -- Browser(s) name and version -- : n/a -- Error-message(debug-mod must be tuned on) -- : n/a  My client sells flooring - carpet, hardwood, etc - by the square foot. I've installed the Custom Quantity plugin to allow a customer to purchase a quantity with a decimal, but is there a way for me to set an inventory quantity in the product to include a decimal? And, then to maintain the remaining inventory to the decimal when the client purchases to the decimal?")*

Hi,

Well, the simplest would be to leave the quantity as unlimited and then:
1. create a custom product field to store the stock with decimals.
2. create a custom item field to allow the customer to enter a quantity with decimals on the frontend
3. create a HikaShop plugin and implement different events to update the value, change the price, etc:
- with the onAfterProductQuantityCheck event, you can check that the requested quantity in the custom item field is smaller than the available stock in the custom product field:
[ www.hikashop.com/support/documentation/6...ProductQuantityCheck](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#onAfterProductQuantityCheck)
- with the onBeforeCalculateProductPriceForQuantity or onAfterCalculateProductPriceForQuantity event, you can change the price of the product in the cart based on the value entered in the custom item field:
[ www.hikashop.com/support/documentation/6...ductPriceForQuantity](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#onBeforeCalculateProductPriceForQuantity)
- with the onAfterOrderCreate and / or onAfterOrderUpdate events, you can update the value of the custom product field based on the value entered by the customer in the custom item field:
[ www.hikashop.com/support/documentation/6...l#onAfterOrderCreate](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#onAfterOrderCreate)

The main drawback of this solution is that you don't actually use the quantity system of HikaShop. So the quantity column in the cart / order will always be "1". It's possible to hide it (same with the normal quantity input field). Also, the "out of stock" or "waitlist" plugins won't take your custom product field into account.

However, the advantage is that you don't need to modify any core files of HikaShop. Just a plugin with 100 to 200 lines of code and 2 custom fields (and maybe some CSS to hide the quantity to 1 here and there ) should be enough.

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

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