Spree::LineItem decimal quantity

109 views
Skip to first unread message

Dimitris Stefanidis

unread,
Oct 14, 2013, 7:23:50 AM10/14/13
to spree...@googlegroups.com
Hi All,

I am using spree in order to create a store that will sell fresh food products like tomatoes, carrots e.t.c. The problem I am facing is that people might want to buy various quantities of each product. For example someone might want to buy 700 grams of tomatoes, 1.5 kilos of carrots e.t.c. In order to solve this I could create a variant that is a package of 1/2 Kg and then constrain the orders to multiples of 1/2 Kg. If someone wants 2 kilos of tomatoes he would have to order 4 x 1/2 Kg packs. This is not the most user friendly experience. I would prefer that the user sees 2Kg when visiting his shopping cart and checking out. 

What I am thinking to do in order to solve this is to allow decimals for a line item quantity and decimals for the count_on_hand column of spree_stock_items. This might provide a solution but before trying it out I would appreciate any expert opinions out there on what implications this might have on the operation of the store. 

Thanks,
Dimitris

Jonathan O'Connor

unread,
Oct 14, 2013, 10:21:21 AM10/14/13
to spree...@googlegroups.com
Dimitris,
I've actually been looking at removing the quantity field, as it doesn't make sense in my shop (yes, it's a strange world).
I think you can probably get away with writing a migration to change the column type, changing a validation here or there, to disable only_integer, and then try it out.
You may have to change the OrderPopulator.

Warning: I'm a Spree Newbie, so don't trust what I say.
Hope this helps,
Jonathan

Pau Pérez Fabregat

unread,
Sep 29, 2017, 10:04:54 AM9/29/17
to Spree
Hi Dimitris,

I know this issue was raised very long ago but I happen to be in the exact same situation. Did you find a solution? How did you proceed?

Does anyone else have any idea how could this be solved? Having to maintain a fork in order to have this feature sound somewhat scary.

Thanks,
Pau

El dilluns, 14 octubre de 2013 13:23:50 UTC+2, Dimitris Stefanidis va escriure:
Reply all
Reply to author
Forward
0 new messages