• Resolved emanuelemn

    (@emanuelemn)


    Hi,

    I want the new products added to the site to be automatically assigned a category.

    How can I do this?

    Thank you for the answers

    • This topic was modified 2 years ago by emanuelemn.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @emanuelemn

    Thanks for reaching out!

    I understand that you want the newly created products on your site to be assigned a category automatically, correct?

    Out-of-the-box, this could be done with the help of some third-party plugins or a custom code.

    I did some research and found this article could be a good starting point: Automatically Add WooCommerce Product Tags and Categories

    Hope this helps!

    Thread Starter emanuelemn

    (@emanuelemn)

    Yes, that’s what I want.
    The module you are talking about does not work correctly for this

    Hi @emanuelemn

    Thanks for your confirmation. I understand that the article I shared above does not work correctly on your site.

    As I’ve mentioned earlier that this is an out-of-the-box function which could be achieved thru some third-party plugins or custom code, you can check this link for some results that might fit your need: https://www.google.com/search?client=firefox-b-d&q=assign+categories+autoamtically+to+woo+products+upon+creatoin

    In addition, you could also check the channels below for questions related to development and custom coding. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, too.

    Hope this helps!

    Thread Starter emanuelemn

    (@emanuelemn)

    Hi,

    I solved it with this code:

    //Add automatically to the “All active campaigns” category with ID 111
    function adauga_categorie_la_produs($new_status, $old_status, $post) {
    // We check if the post is of type “product” and has been published for the first time
    if ($post->post_type === ‘product’ && $new_status === ‘publish’ && $old_status !== ‘publish’) {
    // Add the category with ID 111 to the product
    wp_set_post_terms($post->ID, array(111), ‘product_cat’, true);
    }
    }
    add_action(‘transition_post_status’, ‘adauga_categorie_la_produs’, 10, 3);

    Roxy

    (@roxannestoltz)

    Hi @emanuelemn ,

    Thanks for sharing what has worked for you, this will be very helpful for others that may be looking to achieve the same ??

    Since this has been resolved, feel free to create a new topic should you need any further help.

    Cheers!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Automatically Assign Categories to prodact’ is closed to new replies.