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

#   How to change quantity and sell product by Kg?

##

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

Less More

- Posts: 6
- Thank you received: 0
-
-

11 years 6 months ago [\#199643](#199643) by [Ducnb](/forum/user/34054-ducnb "View Ducnb's Profile")  *[How to change quantity and sell product by Kg?](/forum/4-how-to/876568-how-to-change-quantity-and-sell-product-by-kg#199643 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.3  Hi . My website sell fruit, I want setup sell product follow kg, example: 1kg apple have price $20 ==&gt; if user buy 0.5kg will have price is $10 how to do that ? how to setup quantity dropdown field have: 0,5kg, 1kg, 1.5kg, 2kg, 2.5kg ? Please see my image to understand my idea.  Please help me.")* was created by *[Ducnb](/forum/user/34054-ducnb "View Ducnb's Profile")*

-- HikaShop version -- : 2.3.5
-- Joomla version -- : 3.4.1
-- PHP version -- : 5.3

Hi .
My website sell fruit, I want setup sell product follow kg, example:
1kg apple have price $20 ==&gt; if user buy 0.5kg will have price is $10
how to do that ?
how to setup quantity dropdown field have: 0,5kg, 1kg, 1.5kg, 2kg, 2.5kg ?
Please see my image to understand my idea.

[ ![quatity.jpg](/forum/attachment/23997) ](/forum/attachment/23997 "quatity.jpg")

Please help me.

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

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

11 years 6 months ago [\#199682](#199682) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[How to change quantity and sell product by Kg?](/forum/4-how-to/876568-how-to-change-quantity-and-sell-product-by-kg#199682 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.3  Hi . My website sell fruit, I want setup sell product follow kg, example: 1kg apple have price $20 ==&gt; if user buy 0.5kg will have price is $10 how to do that ? how to setup quantity dropdown field have: 0,5kg, 1kg, 1.5kg, 2kg, 2.5kg ? Please see my image to understand my idea.  Please help me.")*

Hi,

This topic has the sdolution ![;)](/media/kunena/emoticons/24.png ";)")
[ www.hikashop.com/forum/4-how-to/20874-price-by-weight.html](http://www.hikashop.com/forum/4-how-to/20874-price-by-weight.html)

You have to use the characteristics.

The following user(s) said Thank You: [Ducnb](/forum/user/34054-ducnb "View Ducnb's Profile")

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

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

Less More

- Posts: 6
- Thank you received: 0
-
-

11 years 6 months ago [\#200693](#200693) by [Ducnb](/forum/user/34054-ducnb "View Ducnb's Profile")  Replied by *[Ducnb](/forum/user/34054-ducnb "View Ducnb's Profile")* on topic *[How to change quantity and sell product by Kg?](/forum/4-how-to/876568-how-to-change-quantity-and-sell-product-by-kg#200693 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.3  Hi . My website sell fruit, I want setup sell product follow kg, example: 1kg apple have price $20 ==&gt; if user buy 0.5kg will have price is $10 how to do that ? how to setup quantity dropdown field have: 0,5kg, 1kg, 1.5kg, 2kg, 2.5kg ? Please see my image to understand my idea.  Please help me.")*

Thank you very much.
I know code and I changed quantity dropdown to: 0.5 , 1.0, 1.5, .... (Kg) in ovewrite file /html/hikashop_button.php and write function hikashop_button_render()
But when I add to cart (Example: I select qty 0.5) I see ajax send but dont have any result response, that mean, my product dont add to cart.
Please let me know, how to I can change this ? I must change code in core file or must create plugin. I want create plugin becasue I want upgrade in future.
Please help me.
Thank you.

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

11 years 6 months ago [\#200711](#200711) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[How to change quantity and sell product by Kg?](/forum/4-how-to/876568-how-to-change-quantity-and-sell-product-by-kg#200711 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.3  Hi . My website sell fruit, I want setup sell product follow kg, example: 1kg apple have price $20 ==&gt; if user buy 0.5kg will have price is $10 how to do that ? how to setup quantity dropdown field have: 0,5kg, 1kg, 1.5kg, 2kg, 2.5kg ? Please see my image to understand my idea.  Please help me.")*

Hi,

In HikaShop the quantity is an integer, so it is not possible to have half quantities.
So it will require a lot of modifications for this behaviour.

The best solution could be to use a custom item field for the weight, and then use the plugin "system / custom quantity weight" to do a price calculation based on the weight custom field.

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

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

Less More

- Posts: 6
- Thank you received: 0
-
-

11 years 6 months ago -  11 years 6 months ago [\#200804](#200804) by [Ducnb](/forum/user/34054-ducnb "View Ducnb's Profile")  Replied by *[Ducnb](/forum/user/34054-ducnb "View Ducnb's Profile")* on topic *[How to change quantity and sell product by Kg?](/forum/4-how-to/876568-how-to-change-quantity-and-sell-product-by-kg#200804 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.3  Hi . My website sell fruit, I want setup sell product follow kg, example: 1kg apple have price $20 ==&gt; if user buy 0.5kg will have price is $10 how to do that ? how to setup quantity dropdown field have: 0,5kg, 1kg, 1.5kg, 2kg, 2.5kg ? Please see my image to understand my idea.  Please help me.")*

Hi,
I will create plugin. I see have plugin: system/custom_quantity_tax and have some function. Can you let me know some function can use for my plugin or Can you give me link to API for this work ? I realy need it.

in this document: [ www.hikashop.com/support/documentation/6...tation.html#override](http://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#override)
**For the product quantity calculation** I only see calculate for **hikashop\_product\_price\_for\_quantity\_in\_cart()** and **hikashop\_product\_price\_for\_quantity\_in\_order()** If I use ajax, how to calculate price ?

Thank you very much.

Last edit: 11 years 6 months ago by [Ducnb](/forum/user/34054-ducnb "View Ducnb's Profile").

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

Less More

- Posts: 86541
- Thank you received: 14304
-
-

11 years 6 months ago [\#200842](#200842) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to change quantity and sell product by Kg?](/forum/4-how-to/876568-how-to-change-quantity-and-sell-product-by-kg#200842 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.3  Hi . My website sell fruit, I want setup sell product follow kg, example: 1kg apple have price $20 ==&gt; if user buy 0.5kg will have price is $10 how to do that ? how to setup quantity dropdown field have: 0,5kg, 1kg, 1.5kg, 2kg, 2.5kg ? Please see my image to understand my idea.  Please help me.")*

Hi,

Wait a bit. Why not simply use a characteristic for the selection of the weight ?
You could then set the price of each weight variant of the product and it would work automatically like you want.
[ www.hikashop.com/support/support/documen...html#characteristics](https://www.hikashop.com/support/support/documentation/integrated-documentation/19-hikashop-product-form.html#characteristics)

If nevertheless you want to use a custom field coupled with a custom plugin, it is mainly for the calculation of the product price once added to the cart. If you want to refresh the price on the product page when you change the selection in the field, it will require the modification of the file "show_block_custom_item to add your own javascript call when the dropdown is changed so that you can update the price displayed manually on the page.

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

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

Less More

- Posts: 29
- Thank you received: 1
-
-

9 years 4 days ago [\#282217](#282217) by [heinburgh@gmail.com](/forum/user/53446-heinburgh-gmail-com "View heinburgh@gmail.com's Profile")  Replied by *[heinburgh@gmail.com](/forum/user/53446-heinburgh-gmail-com "View heinburgh@gmail.com's Profile")* on topic *[How to change quantity and sell product by Kg?](/forum/4-how-to/876568-how-to-change-quantity-and-sell-product-by-kg#282217 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.3  Hi . My website sell fruit, I want setup sell product follow kg, example: 1kg apple have price $20 ==&gt; if user buy 0.5kg will have price is $10 how to do that ? how to setup quantity dropdown field have: 0,5kg, 1kg, 1.5kg, 2kg, 2.5kg ? Please see my image to understand my idea.  Please help me.")*

I'm selling meat per kg, I used characteristics to allow the customer to buy 0.5, 0.75, 1, 1.5 and 2kg. Now the issue is with stok numbers. If I have 50kgs in stock, and the customer buys 10 x 2kg packs, it only deducts 10kgs from the stock, not 20kg.

Is there a function to address this or is it down to custom php coding?

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

Less More

- Posts: 86541
- Thank you received: 14304
-
-

9 years 3 days ago [\#282227](#282227) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to change quantity and sell product by Kg?](/forum/4-how-to/876568-how-to-change-quantity-and-sell-product-by-kg#282227 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.3  Hi . My website sell fruit, I want setup sell product follow kg, example: 1kg apple have price $20 ==&gt; if user buy 0.5kg will have price is $10 how to do that ? how to setup quantity dropdown field have: 0,5kg, 1kg, 1.5kg, 2kg, 2.5kg ? Please see my image to understand my idea.  Please help me.")*

Hi,

There is no system to have a coefficient on the quantity of the variants of products.
So that would require custom plugin to calculate that if you decide to keep it like that.

Alternatively, you could have your quantity in grams. So for example, you would have 50000 of stock if you have 50kg of that product in stock.
And then, instead of using variants, you could instead add prices with "minimum quantity" for each step you want for the selection and then set the "quantity input method" option of the product to "show select price".
So if you have prices like that for the product:
min qty &#124; price
500 &#124; x
750 &#124; x*1.5
1000 &#124; x*2
...etc...
You would get a quantity input as a dropdown with the quantities 500, 750, 1000, etc available in it.
That way, you would get a unified stock control for all the choices, but you'll loose a bit on display since you can choose what will be displayed in the dropdown for each choice. It will just be the numbers (unless you customize the display of course).

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

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