How to change quantity and sell product by Kg?

  • Posts: 6
  • Thank you received: 0
3 years 1 day ago #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 ==> 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.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2315
  • MODERATOR
3 years 20 hours ago #199682

Hi,

This topic has the sdolution ;)
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

Please Log in or Create an account to join the conversation.

  • Posts: 6
  • Thank you received: 0
2 years 11 months ago #200693

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 or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2315
  • MODERATOR
2 years 11 months ago #200711

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 or Create an account to join the conversation.

  • Posts: 6
  • Thank you received: 0
2 years 11 months ago #200804

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
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: 2 years 11 months ago by Ducnb.

Please Log in or Create an account to join the conversation.

  • Posts: 61836
  • Thank you received: 8793
  • MODERATOR
2 years 11 months ago #200842

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

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 or Create an account to join the conversation.

  • Posts: 29
  • Thank you received: 1
  • Hikashop Essential
5 months 2 weeks ago #282217

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 or Create an account to join the conversation.

  • Posts: 61836
  • Thank you received: 8793
  • MODERATOR
5 months 1 week ago #282227

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 | price
500 | x
750 | x*1.5
1000 | 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 or Create an account to join the conversation.

Time to create page: 0.091 seconds
Powered by Kunena Forum