public function updateCartObject($cart) {
    if (isset($cart->customer_id)) {
      $cart->customer_id = (string) $cart->customer_id;
    }

    // Some ecommerce backends, like hybris, don't save the billing like they
    // do with shipping. So if a billing was set we don't want it to be
    // overwritten when the API response comes back.
    $current_billing = $this->getBilling();
    if (!empty($current_billing) && empty($cart->billing)) {
      $cart->billing = $current_billing;
    }

    if (isset($cart->carrier)) {
      // We use it as array internally everywhere, even set as array.
      $cart->carrier = (array) $cart->carrier;

      // If carrier is with empty structure, we remove it.
      if (empty($cart->carrier['carrier_code'])) {
        unset($cart->carrier);
      }
    }

    $this->cart = $cart;
    $this->updateCartItemsCount();
  }