Is there a way when adding a new product that all available Attributes would automatically be added to this product and oppened/expanded so that when I’m adding new product I don’t have to first add them and then click on the headers to expand them?
Hope this image clears what I want to achieve:
Sure, I can manually trigger the click on “Expand all” button with jQuery, but am having trouble finding the place where to add this piece of jQ code. More important to me is the former question though, so any push in the right direction is much appreciated.
edit: I managed to do the open(show) part of the problem by adding the line:
jQuery('.expand_all').trigger("click");
in the themes/mytheme/admin/admin-functions.php file in siteoptions_admin_head function. But the first qq still remains. I did find a work around though – I could first add one product and add every existing attribute to it, and when making new products I would make a copy of this product and them add/remove attributes I don’t need. This however would not work dynamically if attributes change, so its not much of an improvement.
This was not as easy as I initially thought.
This will show show every attribute…. apparently by default WC hides any attribute that doesn’t have any terms. They’re already in the code, just with a
display:none;
.Depending on whether you plan to click all the “Visible on the product page” checkboxes, you can add some data to the attributes for a particular post when it is created. Per some other WPA questions, I’ve hooked into
transition_post_status
. The “auto-draft” status, supposedly only fires on first creation… from there it either goes to “draft” or any of the other post statuses.pa_capacity
andpa_color
are just some sample attributes that I already had installed.PS- I would suggest updating
wpa_120062_scripts
to only display on product edit screens, but I’m a little fried after that.EDIT
We can use the woocommerce function
wc_get_attribute_taxonomies()
to dynamically get all the attributes and loop through them:PS- I think the defaults are going to be a little different in WC2.1. This isn’t quite working the same for me any longer with my bleeding edge git versions.
WC 2.1 update: