Allow fractional quantity

  • Posts: 1
  • Thank you received: 0
13 years 3 months ago #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 "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 :)




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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
13 years 3 months ago #24006

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

  • Posts: 27
  • Thank you received: 1
11 years 7 months ago #100557

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

  • Posts: 13201
  • Thank you received: 2322
11 years 7 months ago #100742

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

  • Posts: 27
  • Thank you received: 1
11 years 7 months ago #100744

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

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
11 years 7 months ago #100832

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 5 months ago #270426

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

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

Time to create page: 0.092 seconds
Powered by Kunena Forum