Published/Draft/Pending counts are incorrect based on product status
-
Hi there,
I’m having an issue with the wcfm_get_user_posts_count() function in the wc-frontend-manager/helpers/wcfm-core-functions.php file, where it is incorrectly calculating the number of posts based on their status.
For example, all the products have a ‘publish’ status for this one vendor, with 23 published products in total, but when you look at the numbers that wcfm_get_user_posts_count() is generating, they are incorrect:
It’s showing that 23 products are published, 23 are draft, and 23 are pending (92 in total)… but in reality, only 23 should be shown as published, with 23 in total.
I’ve been manually changing this function to properly get the product post counts, based on their status, by changing this function like so:
function wcfm_get_user_posts_count( $user_id = 0, $post_type = 'product', $post_status = 'publish', $custom_args = array() ) { global $wpdb; $count = $wpdb->get_var( $wpdb->prepare( " SELECT COUNT(ID) FROM $wpdb->posts WHERE post_type = %s AND post_status = %s AND post_author = %d", $post_type, $post_status, $user_id ) ); return ($count) ? $count : 0; }
Then, the counts are returned correctly based on the actual product post status:
Just wanted to mention this to have you look into it, as I have to update this function every time an update is released.
Thank you!
- The topic ‘Published/Draft/Pending counts are incorrect based on product status’ is closed to new replies.