private function resolveCarts(
        CustomerInterface $customer,
        CartInterface $cartFromCustomer = null,
        CartInterface $cartFromSession = null
    ) {
        if ($cartFromCustomer) {
            return $cartFromCustomer;
        } else {
            if (!$cartFromSession) {

                /**
                 * Customer has no pending carts, and there is no cart in
                 * session.
                 *
                 * We create a new Cart
                 */
                $cart = $this
                    ->cartFactory
                    ->create();
            } else {

                /**
                 * Customer has no pending carts, and there is a cart loaded
                 * in session.
                 *
                 * If customer is not a pristine entity since it has already
                 * been flushed, we associate this cart with customer
                 */
                $cart = $cartFromSession;

                if ($customer->getId()) {
                    $cart->setCustomer($customer);
                    $customer->addCart($cart);
                }
            }

            return $cart;
        }
    }