I am working on a site and they sell fabric and she wants to change the site to accept deimal quantities for her fabric She has a range so I could just add them as variants but ideally I would like to have it where you can just type it in the quantity box. I have tried to do this several times in the past but it ended up becoming a lot more than I originally anticipated. Has anyone attempted to do anything like this or something similar and had it work successfully? Thanks in advance for any help!
in General by (165 points)

1 Answer

0 votes

I'm not an ADNSF employee, but I know enough to tell you that would be, at a conservative estimate, really hard. There are two big impediments. I don't know how much of a programmer you are, so I'll sum up:

  • SQL, the language that's used to access the store's database, requires every piece of data to have a type associated. The quantity in an order (ShoppingCart.Quantity) is of type "integer". You could change that, but there are a lot of SQL queries in the software that probably expect that field to be an integer, and those would all fail. 
  • C#, the language that the store's programming is written in, also requires typed data, and it's going to expect to receive an integer from the database when it asks for the quantity. Receiving a decimal will make it crash spectacularly.

If you changed the data types in every single place in every single dependency, it might work, but then your store would be nearly impossible to upgrade or support. 

The nearest solutions I can think of are:

  • Have a customer-facing option for a decimal, but then, in the back end, multiply that by 10 to make it a whole number, and then make sure to multiply all your database inventory quantities by 10 as well. A bit hacky, but that's probably in the nature of this problem.
  • Do whatever it is that you're thinking of with the variants.
  • Possibly something to do with kit products, or maybe a text field (though that wouldn't allow you to price anything precisely).

Difficult problem, as you've already discovered.

by (425 points)