WooCommerce WordPress can’t find total order after checkout/pyament

Solution:

If it’s the thank you page, then it’s simple enough – you just need to use this and it should work without breaking the page.

In your templates/checkout/thankyou.php file, add this code:

if ( ! $order) {
    echo 'No order object!';
} else if ($order->has_status( 'failed' ) {
    echo 'Order failed for some reason.';
} else {
    echo $order->get_total();
}

If you don’t have the $order object, you can get it from the order id:

$order = wc_get_order( $order_id );
$order->get_total();

If you don’t have the order id OR the $order object available, then we need more information to be able to help.