Woocommerce, add separate tax totals and price total to order list page

I am using a plugin https://wordpress.org/plugins/purchased-items-column-woocommerce/

which adds an ajax display of the orders items on the orders list page of woocommerce, so you do not need to fully open the order. I want to add (1) the display of taxes and (2) total cost of products to this. I have tried various things but cant quite seem to extract the right items from $order.

  1. Some places have 1 tax rate, some have 2 (say a local and a state tax). I want to display the total tax actually paid (after discounts etc) for EACH rate with the name of the tax rate beside it.

  2. Actual total price of products. The price minus discounts and not including any other things like shipping or taxes.

Right now it shows
1 x pair of sock
2 x pillow
3 x spatula

I want it to display
1 x pair of socks
2 x pillow
3 x spatula
Quebec QST: $5.25
Quebec GST: $12.75
Order total: $170

The plugin function I want to modify is below. (As this is a very basic plugin I am happy to maintain my own fork of it)

    function pipdig_wc_find_products_ajax() {
        $output = '';

        $order_id = intval($_POST['order_id']);
        $order = new WC_Order($order_id);
        $products = $order->get_items();
        //var_dump($order);

    foreach($products as $product){
        $output .= absint($product['quantity']).' &times; '.esc_html($product['name']).'<br />';
    }

    echo $output;
    wp_die();
}
add_action( 'wp_ajax_pipdig_wc_find_products_ajax', 'pipdig_wc_find_products_ajax' );

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.