I'm trying to get the order information inside the mymodule_preprocess_page hook.
On the normal page I can get it via the $cart. But the $cart is not available on the checkout page anymore. How do I get the order information specifically the order_id and order_number.
This is what I do on other pages:
$order_type = 'physical';
$cart_provider = \Drupal::service('commerce_cart.cart_provider');
$store = \Drupal::service('commerce_store.current_store')->getStore();
$cart = $cart_provider->getCart($order_type, $store);
if ($cart) {
foreach ($cart->getItems() as $order_item) {
$orderId = $order_item->get('purchased_entity')[0]->get('target_id')->getValue();
}