I’ve added this snippet which works. What would be the easiest way to add a category filter to it?
// function that runs when shortcode is called
function report_total_sales() {
global $wpdb;
$order_totals = apply_filters( 'woocommerce_reports_sales_overview_order_totals', $wpdb->get_row( "
SELECT SUM(meta.meta_value) AS total_sales, COUNT(posts.ID) AS total_orders FROM {$wpdb->posts} AS posts
LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
WHERE meta.meta_key = '_order_total'
AND posts.post_type = 'shop_order'
AND posts.post_status IN ( '" . implode( "','", array( 'wc-completed', 'wc-processing', 'wc-on-hold' ) ) . "' )
" ) );
return absint( $order_totals->total_sales);
}
// register shortcode
add_shortcode('total_sales', 'report_total_sales');
Hi there,
I would recommend that you ask in the Advanced WooCommerce Group on Facebook(https://www.facebook.com/groups/advanced.woocommerce) to see if someone can help you out there.
Alternatively, we highly recommend contacting one of the services on our Customizations page (https://woocommerce.com/customizations/)
We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.