WP Woocommerce – Create a select dropdown with attributes for a user uploadform.

I have a site where users can uploa dproducts themself to woocommerce. Im using Meta keys in the uploader to set size, gender and other choices for the products. However, most filer plugins uses attributes and taxomonys to filter product, and Im looking for a way to add Woo Attributes trough the uploader via dropdowns and checkboxes. Would this be possible?

Two example im using – dropdown for categories and one textfield input field with a metakey.

Read More

Categories:

case 'post_categories':
                $options = userpro_publish_categories($args);
                $res .= "<select name='".$key.'-'.$i.'[]'."' multiple='multiple' class='chosen-select' data-custom-error='".__('Please choose a category at least','userpro')."' data-required='".$args['require_category']."' data-placeholder='".$placeholder."'>";
                foreach($options as $k=>$v) {
                    if (strstr($k, 'optgroup_b')) {
                        $res .= "<optgroup label='$v'>";
                    } elseif (strstr($k, 'optgroup_e')) {
                        $res .= "</optgroup>";
                    } else {
                        $res .= "<option value='$k'>$v</option>";
                    }
                }
                $res .= "</select>";
                break;

Text with meta key:

case '_bank_details':
                $res .= "<input data-required='".$args['require_'.$key]."' type='text' name='$key-$i' id='$key-$i' value='".$user_bank."' placeholder='".$placeholder."' />";
                break;

How do I create somethings similar, but for Woo attributes?

Related posts

Leave a Reply