Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have studies the database intensively and know which all tables are updated when a category is added to a product. Is there any inbuilt woocommerce function to add categories? It updates 2 or 3 tables but want to leave it to woocommerce.

Thanks for your help.

share|improve this question

closed as off-topic by toscho May 15 at 2:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

    
have you tried with wp_set_object_terms ? –  adrian7 Jul 28 '13 at 13:07
    
Could you clarify what you are trying to do? Woo's "product categories" are really just a custom taxonomy ( product_cat ) and adrian's suggestion would work fine. –  helgatheviking Jul 28 '13 at 13:08

1 Answer 1

I think the function you are looking for is called wp_insert_term() in WordPress core. Woocommerce uses WordPress-taxonomy called product_cat

So if you want to add some categories for example phones:

function wpse_insert_term()
{
    wp_insert_term(
      'phones',
      'product_cat', // the taxonomy
      array(
        'description'=> 'A yummy phone.',
        'slug' => 'phone',
      )
    );
}
add_action('init', 'wpse_insert_term');
share|improve this answer