'WooCommerce pull report with dynamically added fee

I am adding a fee to the users cart based on the cart totals.

add_action('woocommerce_cart_calculate_fees', function() {
    if (is_admin() && !defined('DOING_AJAX')) {
        return;
    }
 
    $cart_total = WC()->cart->get_cart_contents_total();
    
    switch (true) {
    case $cart_total <= 300:
        $cart_fee = 4.99;
        break;
    case $cart_total > 300 && $cart_total <= 400:
        $cart_fee = 6.64;
        break;
    case $cart_total > 400 && $cart_total <= 500:
        $cart_fee = 8.30;
        break;
    case $cart_total > 500
        $cart_fee = 9.96;
        break;          
    default:
        $cart_fee = 0;
    }   
    
    if ($cart_total > 0) {
        WC()->cart->add_fee(__('Shipping & Handling', 'txtdomain'), $cart_fee);
    }
});

This works fine but now I need to get a report on these fees, daily, monthly, annually, etc.

Can someone point me in the right direction? Would I need to use custom SQL queries on a custom page or might there be a plugin to generate this type of report?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source