• Hello,
    in wordpress 4.6 I need to add to wooCommerce new attributes/attrs with structure like

    Array
    (
        [attribute_id] => 1
        [attribute_name] => brand
        [attribute_label] => Brand
        [attribute_type] => select
        [attribute_orderby] => menu_order
        [attribute_public] => 0
        [attrs] => Array
            (
                [0] => Array
                    (
                        [term_id] => 6
                        [name] => A4Tech
                        [slug] => a4tech
                        [term_group] => 0
                        [term_taxonomy_id] => 6
                        [taxonomy] => pa_brand
                        [description] => 
                        [parent] => 0
                        [count] => 4
                        [filter] => raw
                    )
    
                [1] => Array
                    (
                        [term_id] => 45
                        [name] => Firstblood
                        [slug] => firstblood
                        [term_group] => 0
                        [term_taxonomy_id] => 45
                        [taxonomy] => pa_brand
                        [description] => 
                        [parent] => 0
                        [count] => 5
                        [filter] => raw
                    )
    
                [2] => Array
                    (
                        [term_id] => 34
                        [name] => IBM
                        [slug] => ibm
                        [term_group] => 0
                        [term_taxonomy_id] => 34
                        [taxonomy] => pa_brand
                        [description] => 
                        [parent] => 0
                        [count] => 1
                        [filter] => raw
                    )
    
    I googled and found examples like :
    $parent_term = term_exists( 'fruits', 'product' ); // array is returned if taxonomy is given
    $parent_term_id = $parent_term['term_id'];         // get numeric term id
    wp_insert_term(
        'Apple',   // the term 
        'product', // the taxonomy
        array(
            'description' => 'A yummy apple.',
            'slug'        => 'apple',
            'parent'      => $parent_term_id,
        )
    );

    I tried to make by this example, but failed : I am not still sure is this code for attribute / attr creation.
    Could, you please, explaine or give link for example?

    Thanks!

  • The topic ‘add to wooCommerce new attributes/attrs’ is closed to new replies.