// Hook into WooCommerce 'thank you' page
add_action('woocommerce_thankyou', 'custom_order_confirmation_summary', 10, 1);

function custom_order_confirmation_summary($order_id) {
    // Get order object and details
    $order = wc_get_order($order_id);

    if (!$order) return;

    echo '<h2>Order Confirmation Summary</h2>';

    // Order Number
    echo '<p><strong>Order Number:</strong> ' . $order->get_order_number() . '</p>';

    // Order Date
    echo '<p><strong>Date:</strong> ' . wc_format_datetime($order->get_date_created()) . '</p>';

    // Customer Details
    echo '<p><strong>Customer:</strong> ' . $order->get_formatted_billing_full_name() . '</p>';

    // Email
    echo '<p><strong>Email:</strong> ' . $order->get_billing_email() . '</p>';

    // Order Items
    echo '<h3>Items:</h3><ul>';
    foreach ($order->get_items() as $item_id => $item) {
        $product = $item->get_product();
        echo '<li>' . $product->get_name() . ' x ' . $item->get_quantity() . '</li>';
    }
    echo '</ul>';

    // Order Total
    echo '<p><strong>Total:</strong> ' . $order->get_formatted_order_total() . '</p>';
    
    // Payment Method
    echo '<p><strong>Payment Method:</strong> ' . $order->get_payment_method_title() . '</p>';

    // Shipping Method
    echo '<p><strong>Shipping Method:</strong> ' . $order->get_shipping_method() . '</p>';
}