on 08-29-2018 8:52 PM
We are trying to adjust the product quantity display functionality to be inclusive of non-integer values. Also toggle functionality to respect values other than one (1) when performing increment and decrement operations. For eg. our's is a grocery store where we can buy half a pound of butter.
Tried to extend AddToCarParams.java to change "long" qunatity to "double" but couldn't. Also tried adding a new "double" attribute instead of modifying the existing "quantity", which in turn results in rewriting the whole OOB code from populator, DefaultCommerceAddToCartStrategy and there by validateAddToCnd goes on.
Could anyone please suggest me which one is better approach. or Do we have something better than these.
I would use a different decimal base for quantity
, maybe 100 or even 1000
So, to use your example, the quantity for a butter order entry would not be in kg, but in g
So, quantity 500 = 500g = 1/2 kg
With this trick you can save fractional quantities.
no change in data model and therefore OOTB logic
no rounding errors
But, you have to use this throughout the whole stack (e.g. stock levels, ...) and convert the quantities to different units in the frontend and (probably) when integrating with backend system
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.