- Posts: 1
- Thank you received: 0
Allow fractional quantity
15 years 1 month ago #24005
by one320b
Allow fractional quantity was created by one320b
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!
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.
15 years 1 month ago #24006
by nicolas
Replied by nicolas on topic Re: Allow fractional quantity
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.
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.
13 years 5 months ago #100557
by mancer
Replied by mancer on topic Re: Allow fractional quantity
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.
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.
13 years 5 months ago #100742
by Xavier
Replied by Xavier on topic Re: Allow fractional quantity
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.
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.
13 years 5 months ago #100744
by mancer
Replied by mancer on topic Re: Allow fractional quantity
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.
13 years 5 months ago #100832
by nicolas
Replied by nicolas on topic Re: Allow fractional quantity
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.
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.
9 years 4 months ago #270426
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Re: Allow fractional quantity
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
Time to create page: 0.192 seconds