I am suffering from a bug. Can't get order information. At first, I thought that the problem was in some plugins, turned everything off. And then completely created a new WP with only Woocommerce and a standard theme. Still the same error. Please, help me.
Fatal error: Uncaught Error: Call to a member function get_data() on boolean in W:\domains\cafe2\wp-content\themes\envo-shopper\functions.php:501 Stack trace: #0 W:\domains\cafe2\wp-settings.php(555): include() #1 W:\domains\cafe2\wp-config.php(96): require_once('W:\domains\cafe...') #2 W:\domains\cafe2\wp-load.php(50): require_once('W:\domains\cafe...') #3 W:\domains\cafe2\wp-blog-header.php(13): require_once('W:\domains\cafe...') #4 W:\domains\cafe2\index.php(17): require('W:\domains\cafe...') #5 {main} thrown in W:\domains\cafe2\wp-content\themes\envo-shopper\functions.php on line 501 There has been a critical error on this website.
$order_id = 12;
$order = wc_get_order( $order_id );
$order_data = $order->get_data(); // The Order data
$order_id = $order_data['id'];
$order_parent_id = $order_data['parent_id'];
$order_status = $order_data['status'];