Hello, I'm building a custom plugin for my own personal use. It allows me to view the dimensions of a file I have uploaded. It outputs the height and the width. This part is completed.
What you must do: I have a number of pre-defined print-sizes, which I can list in pixels. For example: A4 equals 1984x2816 pixels A5 equals 1398x1984 pixels 30x30 Square equals 2900x2900 pixels etc.
I would like a script to create a number of HTML checkboxes based on suitability of the pre-defined print-size compared to the uploaded image size. An uploaded image sized 2000x2900 pixels will yield a high quality print, at 240 DPI, when produced at A4 size (requires no less than 1984x2816 pixels).
There should be some deviation allowed, perhaps 500 pixels or 5%, whatever is easier to code.
In this example the script would highlight A4 as the most 'suitable' print size (can be done with a css class 'match') as the exact size is within the deviation of 500 pixels of 5%. All the other print sizes that are smaller than A4 and match the print aspect ratio should now also be available as checkboxes, no additional class should be added. ie. A5 equals 1398x1984 pixels.
The aspect ratio is important. Notice we have a size called '30x30 Square' which equals 2900x29000 pixels. I would like this option to be available as a checkbox, however I want a class attached called 'mismatch', which I will use to note that though the pixel size is suitable, the aspect ratio will be completely incorrect.
A final example. The user supplies image dimensions 1400 x 2000 pixels. Result would be one single checkbox "A5" as it is the only suitable size available. It would have the class 'match', as it is within the deviation of 500 pixels or 5%.
There should follow a 'submit' button, titled 'add to variations.
That ends the first part of the script.
The second part I need your help with; I wish to take the user's selection(s) and create a new attribute group, we'll hard-code it's name "print_dimensions". With each selected checkbox, as above, your script will create a new attribute term (if it does not exist already) and attach to this product, it will also create a variation from the attribute with the default price of: 10.00 and no stock management.
This should all happen via AJAX, with NO page reload.
I can provide some example code, where I have attempted these functions, but I do not have the skill to complete the coding. I need professional help!