I need a script to run within the Admin Dashboard > New Product edit screen. An admin will be shown a number of checkboxes, they will have predefined; names and prices connected to them.
There will be one global attribute name.
You must create a script that will allow the user to, on-the-fly, create variations from the checked boxes. It must happen with AJAX, ideally there should be no requirement to refresh the page.
A user should be able to visit post-new.php and whilst creating the initial, first draft, create attributes / variations from the checkboxes.
The built-in woocommerce 'publish' or 'save' button should not delete or remove these. If it is impossible to retrieve / save post meta without first publishing or saving an initial draft, we can write that in.
I will attach a script that another programmer has completed for me, it is far from perfect. The programmer could not complete to my specifications. Here are the instructions to use this script:
1. Install and Activate 2. Navigate to "Add Product" screen 3. First "Publish" the product 4. Then find the meta box to add attributes via Checkbox, select attribute(s). Press submit button "Add Attribute" 5. Navigate AWAY from the "Add Product" screen - DO NOT press 'Update' as you typically would. 6. If you now visit this product you'll see the attributes are correctly attached, can be edited, can be saved.
The obvious issue with the script I already have- it will not allow the attributes to be added without first publishing the post. Furthermore (most importantly): the user must not press 'Update' as this seems to remove the attributes / variations that have just been added via the checkboxes.