I need to extend the quick filters provided by Woocommerce in the admin product view but I cannot seem to find the proper hook to achieve this, can anyone point me in the right direction?
This is the view that I want to extend with two links that directly filter the product list by a certain category (which is regularly buried deep in the category dropdown so the customer wants it above to have a one click solution):
I've already set up a custom plugin and tried to find the proper hook but to no avail.
Here is how you can add these categories - https://prnt.sc/gFuhHx_BKupB
function add_custom_category_links( $views ) {
global $wp_query;
$taxonomy = 'product_cat';
$current_term = isset( $_GET[ $taxonomy ] ) ? sanitize_text_field( $_GET[ $taxonomy ] ) : '';
$current_status = isset( $_GET['post_status'] ) ? sanitize_text_field( $_GET['post_status'] ) : '';
//Change to categories you want to add
$category_links = array(
'clothes' => 'Clothes',
'shoes' => 'Shoes',
);
$output = array();
foreach ( $views as $key => $view ) {
$output[ $key ] = $view;
if ( $key === 'publish' ) {
foreach ( $category_links as $slug => $name ) {
$class = ( $slug === $current_term ) ? 'current' : '';
$url = add_query_arg(
array(
$taxonomy => $slug,
'post_status' => $current_status,
'post_type' => 'product',
'paged' => 1,
),
admin_url( 'edit.php' )
);
$output[ 'category-' . $slug ] = "<a href='$url' class='$class'>$name</a>";
}
}
}
return $output;
}
add_filter( 'views_edit-product', 'add_custom_category_links' );