Woocommerce order counts
-
Hi, I am trying to filter the orders and product counts so that they show only the counts for the current logged in authors. I have managed to get the orders and product lists in admin to display only to the current author but cant get the order counts to adjust.
The UL above the orders/products is the one with the class of “subsubsub” I cant even find the template file where this is located.
The code I’ve tried is this:
function adjust_order_counts_before_shop_loop( $counts ) {
// Get the current user.
$user = wp_get_current_user();// Check if the current user is an admin.
if ( $user->has_cap( ‘activate_plugins’ ) ) {
return $counts;
}// Get the current author ID.
$current_author_id = $user->ID;// Loop through the counts and adjust them if the current user is not an admin.
foreach ( $counts as $key => $count ) {
if ( $count[‘author’] !== $current_author_id ) {
unset( $counts[ $key ] );
}
}return $counts;
}add_action( ‘woocommerce_before_shop_loop’, ‘adjust_order_counts_before_shop_loop’ );
I also tried this hook:
add_filter( ‘woocommerce_order_counts’, ‘woocommerce_order_count_by_author’ );
Any help would be appreciated ??
- The topic ‘Woocommerce order counts’ is closed to new replies.