How do I share data from a hook to a service/controller? I'm trying to implement a shopping cart feature that requires retrieving the data (total value of cart) from a Commerce order.  The problem is that this is only possible with a hook.  But how am I supposed to pass this data from the hook to a service/controller?  I can't find any documentation on where the return value is sent from a hook and if it exists, it's certainly not placed in a very easy to access place since I've been searching for a few days now.

Trying to implement this hook:

function commerce_cart_order_load($uid = 0) {
  // Retrieve the order ID for the specified user's current shopping cart.
  $order_id = commerce_cart_order_id($uid);

  // If a valid cart order ID exists for the user, return it now.
  if (!empty($order_id)) {
    return commerce_order_load($order_id);
  }

  return FALSE;
}


This should give me an assoc array (or some other data object) of the different elements of an order.  Not sure how I can pass this around or access it anywhere.
For those who may have the same troubles as I do...

I am trying to set a message in Drupal to show on /cart the main cart page.  The data is seemingly already there but it was a bit trickier to actually pull the data into code compared to the Views module just simply inserting a field.  

So I can't say I fully understand how this is working.  But my site uses a multi-store model so it's necessary to specify store ID.  Here is my code:

This isCartNotificationController.php (I changed the route behavior of /cart by setting a default _controller method in RouteSubscriber.php and copy-pasting the CartController.php class from commerce_cart/src/Controllers/CartController.php and making edits.  Now the behavior of the route at /cart is different.

$store = \Drupal::service('commerce_store.current_store')-&gt;getStore();
$cart = \Drupal::service('commerce_cart.cart_provider')-&gt;getCart('default', $store);
$price = $cart-&gt;get('total_price')-&gt;getValue()[0]['number'];
drupal_set_message($price); //shows $19.98


So it's a rough implementation but I can successfully access the cart value using this.  I'll probably make a template or something instead since a drupal_set_message is a little bland.

Lots of Google searches will bring up hooks and extending certain hooks but it doesn't seem like you can practically use those within a service/controller.  

In other words, I misunderstood what a hook was doing.