decimal quantity

21.04.2011 13:50
#1
sylvain
Joomshopping forum user no avatar
Name: sylvain
21.04.2011
Posts: 1
Quote
decimal quantity

Hi,
i need to enable customers to order decimal quantity of products (like 0.8kg of meat...)
Can you telle me what i need to modify in order to enable this ?

Thank you

 
14.05.2011 07:18
#2
popopopo@freemail.hu
Joomshopping forum user no avatar
Name: Dora
01.05.2011
Posts: 4
Quote
Aw: decimal quantity

Hello!

I have the same problem. By any chance, did you get closer to the solution? I found that in order to get this right, I need to change the javascript validator and also the database, but I am in the beginning of the journey. I need to learn javascript first, and the basics of Joomla engine too...

So any help would be useful.

Thanks, Attila

 
14.05.2011 10:02
#3
Dr.Rivera
Joomshopping forum user no avatar
Name: Jürgen
13.09.2010
Posts: 2276
Quote
Aw: decimal quantity

Hello,

maybe it helps:

For example:
You sell meat.
0,1 kg = 1 EUR

If the costumer takes 10, he can buy 1 kg for 10 EUR.
You can Show the weight in the cart.
And you can also show the price for one unit (10 EUR / kg) near the product price.

And you write a notice for your costumers, how they can use 1 or more kg meat.

I know, this is not the best solution, but I have no other idea. Maybe the MODERATORsays to us, that he have a better solution and reprogramming joomshopping...

Moderator: This is a question. Thank you very much.

Greetings


Letzte Änderung: 14.05.2011 15:51

Nicht ganz aktuell, aber vielleicht doch noch für einige hilfreich, das E-Book Joomshopping.
Bei Amazon (kindl) und xinxii (ePub):

http://www.amazon.de/JoomShopping-Joomla-Shop-Online-Shop-ebook/dp/B005L9D8MC

http://www.xinxii.com/joomshopping-der-joomla-shop-p-339561.html
 
14.05.2011 14:59
#4
popopopo@freemail.hu
Joomshopping forum user no avatar
Name: Dora
01.05.2011
Posts: 4
Quote
Aw: decimal quantity

Hello!

Thanks for the tip! I had a thought about it also, but the products are sometimes in KG, sometimes in gramm, sometimes as you suggested, 0.1 kg as basic unit - and it would be misleading to the users to change the factor all the time product by product, OR to keep everything in gramms. I am now deepening into the code of Joomshopping, but it is *complicated* for me :-)

 
14.05.2011 15:44
#5
Dr.Rivera
Joomshopping forum user no avatar
Name: Jürgen
13.09.2010
Posts: 2276
Quote
Aw: decimal quantity

Hello,

yes, not all people are programmer, therefore I´m looking to other solutions.
I think you know that:

You can create different units:
/index.php?option=com_jshopping&controller=units
and so you can choose the right for a definite product.

Yoo can create informations for your costumers with
index.php?option=com_jshopping&controller=productfields

for example:
Costumer, look out: quantity:1 = 100 mg
Costumer, look out: quantity:1 = 500 mg..........
...so you can choose the right for a definite product.

This information can see your costumer
Aw: decimal quantity

Maybe it helps you


Letzte Änderung: 14.05.2011 15:47

Nicht ganz aktuell, aber vielleicht doch noch für einige hilfreich, das E-Book Joomshopping.
Bei Amazon (kindl) und xinxii (ePub):

http://www.amazon.de/JoomShopping-Joomla-Shop-Online-Shop-ebook/dp/B005L9D8MC

http://www.xinxii.com/joomshopping-der-joomla-shop-p-339561.html
 
14.05.2011 22:51
#6
popopopo@freemail.hu
Joomshopping forum user no avatar
Name: Dora
01.05.2011
Posts: 4
Quote
Aw: decimal quantity

Hello!

Joomshopping is great, and it provides workarounds in such cases. But I think I found a solution. Since I am not a programmer either, it took me ages to find the appropriate code (and when you look through pages full of strange php expressions, this is the time when you really appreciate the big work of making this available for free!) So the code you need to change:

file: components/com_jshopping/models/cart.php

in the "function refresh($quantity)" part:

original:
foreach ($quantity as $key => $value) {
$value = intval($value);

to:

foreach ($quantity as $key => $value) {
$value = round($value, 2);

The original cuts off all the decimals, the altered version leaves 2 decimals (increase it if needed).

Beside this you need to change the type of a certain field in the database, because as you succeded to preserve your decimals, those should be stored properly:

table "jos_jshopping_order_item" field "product_quantity", the new type should be e.g. "DECIMAL 9,2" (9 = the total digits, 2 = decimals, so you will be able to store numbers up to 9999999.99) - increase it if needed.

This currently works only when you UPDATE your cart, when you originally add a new item, it will still cut off the decimals (surely it is programmed in a different location). I am looking for it now, if anyone is interested, I will share the findings. If I find it :-)

Have a great day!

 
15.05.2011 10:55
#7
Dr.Rivera
Joomshopping forum user no avatar
Name: Jürgen
13.09.2010
Posts: 2276
Quote
Aw: decimal quantity

Hello,

I´m interested at your solution.
If the solution a completely, please write again.

Good luck for "the rest".

Greetings


Nicht ganz aktuell, aber vielleicht doch noch für einige hilfreich, das E-Book Joomshopping.
Bei Amazon (kindl) und xinxii (ePub):

http://www.amazon.de/JoomShopping-Joomla-Shop-Online-Shop-ebook/dp/B005L9D8MC

http://www.xinxii.com/joomshopping-der-joomla-shop-p-339561.html
 
15.05.2011 12:34
#8
popopopo@freemail.hu
Joomshopping forum user no avatar
Name: Dora
01.05.2011
Posts: 4
Quote
Aw: decimal quantity

Hi,

OK, the rest was quite simple: you need to change one line in file:

components/com_jshopping/controllers/cart.php (note that it is different from the other file with the same name!)

line around the 'add' function:

Original:

$quantity = JRequest::getInt('quantity',1);

To be changed to:

$quantity = round(JRequest::getFloat('quantity',1),2);

Now the next task would be to restrict the user to use decimals only at those products where it is appropriate/allowed, but it is a more difficult challenge. I will focus on other issues...

Thanks for the comments, good luck for the implementation!

 


Copyrights MAXXmarketing GmbH. Alle Rechte vorbehalten
Durch die Nutzung dieser Website stimme ich zu, dass Cookies zur optimalen Gestaltung der Website sowie zur Analyse der Nutzung der Website verwendet werden. Weiterführende Informationen finden Sie hier. OK, einverstanden.