cancel
Showing results for 
Search instead for 
Did you mean: 

Can we have the product quantity to be added inclusive of non-integer values while add to cart.

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

mpern
Employee
Employee
0 Kudos

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