How to show detailed order history on woocommerce product page [closed]

The issue is that you’re showing the info for the order and not the item. You want to print the content based on the item instead, like this:

echo '<h2>Previous Donations for this Nonprofit</h2>';
foreach (get_posts('post_type=shop_order&numberposts=-1&post_status=wc-completed') as $order) {
    $order = new WC_Order($order->ID);

    foreach($order->get_items('line_item') as $item) {
        if ($post->ID == $item['product_id'] || $post->ID == $item['variation_id']) {
            echo '<br>Date: '.$order->order_date; 
            echo '<br>Name: '.$order->billing_first_name . '&nbsp;'  .$order->billing_last_name;
            echo '<br>Email: '.$order->billing_email; 
            echo '<br>Order Total: $'.$order->get_line_total( $item );   
        }  
    }
}

I’m not sure what version of WooCommerce you’re running, but I got an error when trying to query posts with a post_status of publish. Version 2.2+ wants you to check based on their proprietary post statusi. You see that reflected above.