Redirect WooCommerce Category and Tag archives to shop page

Not every WooCommerce store needs or wants a category or tag archive. is_product_category detects if current page is a WooCommerce category archive or not. Similarly, is_product_tag detects if it a product tag archive or not. So with below small snippet we can redirect category and tag archives to shop page.

function careless_redirect_woo_archives() {
    //category or tag archive
    if ( is_product_category() || is_product_tag() ) {
        wp_redirect( wc_get_page_permalink( 'shop' ) );
add_action( 'template_redirect','careless_redirect_woo_archives' );

Code goes in the functions.php file of your active theme.