[proofplan]
The unifying device is to interpret $f$ as a morphism $\varphi : C \to \mathbb{P}^1_k$ given on points by $p \mapsto [1 : f(p)]$. For (1), a globally regular $f$ has finite image (the image of a complete variety is complete, and a complete subvariety of $\mathbb{A}^1_k \subset \mathbb{P}^1_k$ is a finite set of points), so the morphism is constant by irreducibility of $C$. For (2), apply the [Degree Equals Sum of Ramification Indices](/theorems/2174) at the two distinguished points $0 = [1:0]$ and $\infty = [0:1]$ of $\mathbb{P}^1_k$: the preimages of $0$ are exactly the zeros of $f$ (with multiplicities given by $\operatorname{ord}_p(f) > 0$), and the preimages of $\infty$ are exactly the poles of $f$ (with multiplicities $-\operatorname{ord}_p(f) > 0$). Equating both sums to $\deg \varphi$ gives $\sum_{f(p) = 0} \operatorname{ord}_p(f) = \sum_{f(p) = \infty} (-\operatorname{ord}_p(f))$, and the orders at remaining points vanish, producing the global sum identity.
[/proofplan]
[step:Construct the morphism $\varphi : C \to \mathbb{P}^1_k$ associated to $f$]
Let $f \in \mathcal{O}_C(\eta) \setminus \{0\}$ be a nonzero rational function. Define
\begin{align*}
\varphi : C &\to \mathbb{P}^1_k \\
p &\mapsto \begin{cases} [1 : f(p)] & \text{if } \operatorname{ord}_p(f) \geq 0, \\ [1/f(p) : 1] & \text{if } \operatorname{ord}_p(f) < 0. \end{cases}
\end{align*}
On the locus where $f$ is regular, $\varphi$ is given by the polynomial map $p \mapsto [1 : f(p)]$. On the locus where $f$ has a pole, $1/f$ is regular and vanishes (because $\operatorname{ord}_p(1/f) = -\operatorname{ord}_p(f) > 0$), and the formula $[1/f : 1]$ is well-defined and matches $[1 : f]$ where both make sense (i.e., on the open set where neither $f$ nor $1/f$ has a pole). Since $C$ is smooth (in particular, every local ring $\mathcal{O}_{C, p}$ is a discrete valuation ring), every rational function extends to a morphism into $\mathbb{P}^1_k$ in this way: the two formulas glue to a regular morphism on all of $C$ by the [extension of rational maps from smooth curves to projective space](/theorems/???).
[/step]
[step:Prove (1): a globally regular $f$ is constant]
Suppose $f$ is regular at every point of $C$. Then by Step 1, $\varphi$ is given everywhere by $p \mapsto [1 : f(p)]$, so the image of $\varphi$ is contained in the affine open $\mathbb{A}^1_k = \mathbb{P}^1_k \setminus \{[0:1]\}$.
The variety $C$ is projective, hence complete. The image $\varphi(C) \subset \mathbb{P}^1_k$ is a closed subvariety (the image of a complete variety under a morphism is closed). Since $\varphi(C) \subset \mathbb{A}^1_k$ and $\varphi(C)$ is closed in $\mathbb{P}^1_k$, the closure of $\varphi(C)$ in $\mathbb{P}^1_k$ equals $\varphi(C)$, and $\varphi(C)$ is a closed subset of $\mathbb{A}^1_k$.
A closed subset of $\mathbb{A}^1_k$ is either a finite set of points or all of $\mathbb{A}^1_k$. The latter is excluded: $\mathbb{A}^1_k$ is not complete (it is not closed in $\mathbb{P}^1_k$, since $[0:1]$ lies in the closure but not in $\mathbb{A}^1_k$), so $\varphi(C) = \mathbb{A}^1_k$ would contradict the closedness of $\varphi(C)$ in $\mathbb{P}^1_k$. Therefore $\varphi(C)$ is a finite set of points.
But $C$ is irreducible, so $\varphi(C)$ is irreducible (the continuous image of an irreducible space is irreducible). The only irreducible finite subsets of $\mathbb{P}^1_k$ are singletons. Hence $\varphi(C) = \{[1 : c]\}$ for a single value $c \in k$, which means $f \equiv c$ is constant.
[guided]
This is a classical "compactness" argument in the algebraic-geometric form: a complete variety admits no nonconstant globally regular functions. Let us track each step.
(i) The map $\varphi$ has image in $\mathbb{A}^1_k$ because $f$ is everywhere regular, so $f(p) \in k$ is finite at every $p$, so $[1 : f(p)] \in \mathbb{A}^1_k$.
(ii) The image is closed in $\mathbb{P}^1_k$. This is the key use of completeness. The morphism $\varphi : C \to \mathbb{P}^1_k$ has source a complete (= projective) variety. By the [completeness of projective varieties](/theorems/???) — sometimes called the universal closedness or "the image of a projective variety is closed" — the image $\varphi(C)$ is closed in $\mathbb{P}^1_k$. We verify the hypothesis: $C$ is projective, so $C \to \operatorname{Spec} k$ is a proper morphism, and the projection $C \times \mathbb{P}^1_k \to \mathbb{P}^1_k$ is closed. The image $\varphi(C)$ is the image of the graph of $\varphi$ under this projection, hence closed.
(iii) A closed subset of $\mathbb{A}^1_k$ is finite or everything. This is because $\mathbb{A}^1_k$ has Krull dimension $1$, and proper closed subsets are zero-dimensional, i.e., finite unions of points (over an algebraically closed $k$, a finite union of $k$-points).
(iv) But $\varphi(C) \neq \mathbb{A}^1_k$ because $\mathbb{A}^1_k$ is not closed in $\mathbb{P}^1_k$ (its closure adds the point at infinity), so an image that is both equal to $\mathbb{A}^1_k$ and closed in $\mathbb{P}^1_k$ would be contradictory. Hence $\varphi(C)$ is a finite set.
(v) Irreducibility of $C$ propagates to irreducibility of the image (continuous images of irreducibles are irreducible — the only closed sets in $\varphi(C)$ pull back to closed sets in $C$, and $C$'s only proper closed subsets do not cover $C$). The only irreducible finite subsets of any space are singletons. So $\varphi$ is constant, and $f$ is constant.
The hypothesis that $C$ is projective is essential — on the affine line $\mathbb{A}^1_k$, the function $f(x) = x$ is globally regular but nonconstant.
[/guided]
[/step]
[step:Identify zeros and poles of $f$ as preimages of $0$ and $\infty$ in $\mathbb{P}^1_k$]
For statement (2), assume $f$ is nonconstant (the constant case is trivial: $\operatorname{ord}_p(f) = 0$ everywhere). Then $\varphi : C \to \mathbb{P}^1_k$ is a nonconstant morphism, hence finite of some degree $\deg \varphi \geq 1$.
Let $t = X_1/X_0 \in \mathcal{O}_{\mathbb{P}^1_k, [1:0]}$ be a uniformiser at $0 := [1:0]$, and $s = X_0/X_1 \in \mathcal{O}_{\mathbb{P}^1_k, [0:1]}$ a uniformiser at $\infty := [0:1]$. By definition, $\varphi^* t$ and $\varphi^* s$ are rational functions on $C$, and we compute:
For a point $p \in C$ with $\operatorname{ord}_p(f) \geq 0$ (i.e., $f$ is regular at $p$):
\begin{align*}
\varphi^* t = \varphi^*(X_1/X_0) = f, \qquad \operatorname{ord}_p(\varphi^* t) = \operatorname{ord}_p(f).
\end{align*}
Therefore, $\varphi(p) = 0$ if and only if $\operatorname{ord}_p(f) > 0$, i.e., $p$ is a zero of $f$. The ramification index at such $p$ is
\begin{align*}
e_p = \operatorname{ord}_p(\varphi^* t) = \operatorname{ord}_p(f).
\end{align*}
For a point $p \in C$ with $\operatorname{ord}_p(f) < 0$ (i.e., $f$ has a pole at $p$):
\begin{align*}
\varphi^* s = \varphi^*(X_0/X_1) = 1/f, \qquad \operatorname{ord}_p(\varphi^* s) = \operatorname{ord}_p(1/f) = -\operatorname{ord}_p(f) > 0.
\end{align*}
Therefore $\varphi(p) = \infty$ at such points, with ramification index
\begin{align*}
e_p = \operatorname{ord}_p(\varphi^* s) = -\operatorname{ord}_p(f).
\end{align*}
For a point $p \in C$ with $\operatorname{ord}_p(f) = 0$, the rational function $f$ takes a nonzero finite value $f(p) \in k^\times$, so $\varphi(p) = [1 : f(p)] \in \mathbb{P}^1_k \setminus \{0, \infty\}$ — neither $0$ nor $\infty$.
[/step]
[step:Apply the degree formula at $0$ and $\infty$ to conclude (2)]
The fibres $\varphi^{-1}(0)$ and $\varphi^{-1}(\infty)$ are finite (since $\varphi$ is finite). By Step 3:
\begin{align*}
\varphi^{-1}(0) = \{p \in C : \operatorname{ord}_p(f) > 0\}, \qquad \varphi^{-1}(\infty) = \{p \in C : \operatorname{ord}_p(f) < 0\}.
\end{align*}
Hence the set $\{p \in C : \operatorname{ord}_p(f) \neq 0\} = \varphi^{-1}(0) \cup \varphi^{-1}(\infty)$ is finite. (When $f$ is constant, $\operatorname{ord}_p(f) = 0$ everywhere, so this set is empty and the conclusion is trivial.)
Apply [Degree Equals Sum of Ramification Indices](/theorems/2174) — whose hypotheses (a nonconstant morphism $C \to D$ between smooth projective irreducible curves) are satisfied with $D = \mathbb{P}^1_k$ — at $q = 0$:
\begin{align*}
\deg \varphi = \sum_{p \in \varphi^{-1}(0)} e_p = \sum_{p : \operatorname{ord}_p(f) > 0} \operatorname{ord}_p(f).
\end{align*}
At $q = \infty$:
\begin{align*}
\deg \varphi = \sum_{p \in \varphi^{-1}(\infty)} e_p = \sum_{p : \operatorname{ord}_p(f) < 0} (-\operatorname{ord}_p(f)).
\end{align*}
Subtracting the second from the first:
\begin{align*}
0 = \sum_{p : \operatorname{ord}_p(f) > 0} \operatorname{ord}_p(f) - \sum_{p : \operatorname{ord}_p(f) < 0} (-\operatorname{ord}_p(f)) = \sum_{p : \operatorname{ord}_p(f) > 0} \operatorname{ord}_p(f) + \sum_{p : \operatorname{ord}_p(f) < 0} \operatorname{ord}_p(f).
\end{align*}
Since $\operatorname{ord}_p(f) = 0$ for all other $p$, the right-hand side is $\sum_{p \in C} \operatorname{ord}_p(f)$, and we obtain
\begin{align*}
\sum_{p \in C} \operatorname{ord}_p(f) = 0.
\end{align*}
[guided]
The argument is a beautiful application of the local-global principle for finite morphisms of curves. Two strands meet at the conclusion.
\textbf{Strand 1 (zeros).} The zeros of $f$ are the preimages of $[1:0] \in \mathbb{P}^1_k$ under $\varphi$. The local picture: at a zero $p$ of order $\operatorname{ord}_p(f) = m > 0$, we have $f = u_p s_p^m$ for $s_p$ a uniformiser at $p$ and $u_p \in \mathcal{O}_{C, p}^\times$; meanwhile $t = X_1/X_0$ is a uniformiser at $[1:0] \in \mathbb{P}^1_k$. Pulling back $t$ to a function on $C$ near $p$, $\varphi^* t = f$, so $\operatorname{ord}_p(\varphi^* t) = m = \operatorname{ord}_p(f)$. By the very definition of ramification index, $e_p = m = \operatorname{ord}_p(f)$.
The degree formula at $q = [1:0]$ then says
\begin{align*}
\deg \varphi = \sum_{p \in \varphi^{-1}(0)} e_p = \sum_{p : \operatorname{ord}_p(f) > 0} \operatorname{ord}_p(f),
\end{align*}
which is the total order of zeros of $f$.
\textbf{Strand 2 (poles).} The poles of $f$ are the preimages of $[0:1] \in \mathbb{P}^1_k$. At a pole $p$ of order $-\operatorname{ord}_p(f) = m > 0$, $1/f = u_p s_p^m$ with $u_p \in \mathcal{O}_{C, p}^\times$, and $s = X_0/X_1$ is a uniformiser at $[0:1]$. Pulling back $s$, $\varphi^* s = 1/f$, so $\operatorname{ord}_p(\varphi^* s) = m = -\operatorname{ord}_p(f) > 0$, giving $e_p = -\operatorname{ord}_p(f)$.
The degree formula at $q = [0:1]$ then says
\begin{align*}
\deg \varphi = \sum_{p : \operatorname{ord}_p(f) < 0} (-\operatorname{ord}_p(f)),
\end{align*}
which is the total order of poles of $f$ (counted positively).
\textbf{The cancellation.} Both strands compute the same degree. Subtracting:
\begin{align*}
\sum_{\text{zeros}} \operatorname{ord}_p(f) - \sum_{\text{poles}} (-\operatorname{ord}_p(f)) = 0.
\end{align*}
Rewriting $-(-\operatorname{ord}_p(f)) = \operatorname{ord}_p(f)$ and combining with the zero contributions $\operatorname{ord}_p(f) = 0$ from points that are neither zeros nor poles, the identity becomes $\sum_{p \in C} \operatorname{ord}_p(f) = 0$.
\textbf{Why $0$ and $\infty$?} They are arbitrary distinct points of $\mathbb{P}^1_k$, but $0$ and $\infty$ are the only ones with the special property that $0 = V(X_1)$ and $\infty = V(X_0)$ are the zero and pole loci of the rational coordinate $f$ itself when viewed via $\varphi$. Choosing them is the same as encoding "zero of $f$" and "pole of $f$" as the geometric data of a morphism.
[/guided]
[/step]