How do I load the current items in cart of the anonymous user? I am working on a custom module for our payment system using Drupal 8 and Commerce 2. When a user removes and item for the cart or updates the quantity, I need to sync the two systems (our internal and Drupal commerce's cart). Our site has one store and all products are associated with that store.
I need to be able to load (and loop) over all the items still in the cart after the CartOrderItemRemoveEvent and the CartOrderItemUpdateEvent events. I tried using the following code, but the order is an empty array, despite the cart still having other items in it.
$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()-&gt;id()); //Which is 0 for anonymous
$order = \Drupal::entityTypeManager()-&gt;getStorage('commerce_order')-&gt;loadByProperties(['uid' =&gt; $user-&gt;get('uid')-&gt;value, 'cart' =&gt; '0']);

Is there a way to get the anonymous user's cart and a list of items still in that cart?
//updated
 public function cartItemRemoved(CartOrderItemRemoveEvent $event) {
      $cart_provider = \Drupal::service('commerce_cart.cart_provider');
      $cart = $cart_provider-&gt;getCart('default');
      $order_items = $cart-&gt;order_items-&gt;referencedEntities();
    \Drupal::logger('current cart items')-&gt;info('&lt;pre&gt;&lt;code&gt;' . print_r(json_encode($order_items), TRUE) . '&lt;/code&gt;&lt;/pre&gt;');

}
Get the current anonymous user's cart

  $cart_provider = \Drupal::service('commerce_cart.cart_provider');
  $cart = $cart_provider-&gt;getCart('default');


Get a list of items still in that user's cart

$order_items = $cart-&gt;order_items-&gt;referencedEntities();


Bonus
$cart_manager = \Drupal::service('commerce_cart.cart_manager');

Update order item
$cart_manager-&gt;updateOrderItem($cart, $order_item);

Remove order item
$cart_manager-&gt;removeOrderItem($cart, $order_item);

Empty cart
$cart_manager-&gt;emptyCart($cart);

Create order item
$order_item = $cart_manager-&gt;createOrderItem($entity, $quantity);

Add order item
$cart_manager-&gt;addOrderItem($order_item);