Open nooysters opened 8 years ago
I don't think there's a specific model as it monkeypatches stuff, so I don't think you'll be able to do anything as simple as validates_numericality_of :width
for example. The validation should probably go with the calculator logic, and there is a method in there for checking whether it's valid: https://github.com/spree-contrib-variants/spree_product_customizations/blob/master/app/models/spree/calculator/product_area.rb#L48
Now I have no idea what happens if it's not valid—does it give the user a nice error? I'm not super optimistic but I think that's your starting point. If it doesn't make a nice error you could try doing something with the variant
passed in but I don't think that will help as if I remember correctly it's a new blank Variant
not the actual LineItem
being edited—which I think is silly but it's too late to change how Spree works now.
Anyway feel free to let me know progress, it's a good idea :)
When it fail the calculator validation i just uses the base price regardless of area. I will play with it and see what I can do. Thanks for the tips!
There doesn't seem to be any backend validation for the area calculator. I am able to use letters for instance. It will default to the minimum area price but it still makes for a confusing customer experience. I am happy to add validation but am not sure which model to edit. Any guidance appreciated.