Delete WooCommerce un-published products

I have almost 11000 pending products that I wish to delete without publishing them. Can you please help me with this?

  • Kris Tomczyk
    • Support

    Hi Susan

    I hope you are doing good today.

    I escalate this to our SLS team so they could check what kind of SQL Query you should run in your database. We will post an update here as soon as more information is available.

    Please keep in mind that our SLS Team deals with more complicated issues, so it may take a little longer for them to reply here. Thank you for your patience while we look into this further.

    Kind Regards,
    Kris

  • Alessandro
    • Nightcrawler & Daydreamer

    Hello Susan.

    I checked your WordPress installation and came up with a MySQL solution.

    Use the following MySQL DELETE commands to delete all pending products and their data as well from the database.

    The following command will delete any product related meta information.
    This will affect 377500 rows.
    DELETE FROM wp_cz2874_postmeta WHERE wp_cz2874_post_id IN ( SELECT ID FROM wp_cz2874_posts WHERE post_status LIKE 'pending' AND post_type LIKE '%product%' );

    The following command will delete any product related information (like attachments etc).
    This will affect 34 rows.
    DELETE FROM wp_cz2874_posts WHERE wp_cz2874_posts.post_parent IN ( SELECT ID FROM wp_cz2874_posts WHERE post_status LIKE 'pending' AND post_type LIKE '%product%' );

    The following command will delete all pending products.
    This will affect 11042 rows.
    DELETE FROM wp_cz2874_posts WHERE post_status LIKE 'pending' AND post_type LIKE '%product%';

    Let us know if this worked for you. :blush:

    :warning: Note: Always make a backup before altering the database. Run the above command at the given order. Any uploaded files do not get deleted.

    Kind regards,
    Alessandro.