In addition to Anton Petrunin's answer, I would like to mention that a more combinatorial argument is possible. Indeed, in a CAT(0) cube complex $X$, a *full* subcomplex $Y$ (i.e. a subcomplex which contains a cube if it already contains its vertices) is convex with respect to the CAT(0) metric if and only if it is convex with respect to the combinatorial metric; see Theorem 2.13 in Haglund's article *Finite index subgroups of graph products*. In other words, it suffices to show that the one-skeleton of $Y$ is convex in $X$ endowed with the graph metric. Now, the proposition is a straightforward consequence of the following two observations:

**Proposition 1:** *Let $X$ be a CAT(0) cube complex and $\alpha,\beta$ two combinatorial paths with the same endpoints. Assume $\beta$ is a geodesic. There exists a sequence of combinatorial paths $\gamma_1=\alpha, \gamma_2,\ldots, \gamma_{n-1},\gamma_n=\beta$ such that, for every $1 \leq i \leq n-1$, $\gamma_{i+1}$ is obtained from $\gamma_i$ by removing a backtrack or flipping a square.*

Here, by *flipping a square*, I mean replacing two consecutive edges of a square by the other two consecutive edges.

**Proposition 2:** *Let $X$ be a CAT(0) cube complex and $\alpha,\beta$ two combinatorial geodesics with the same endpoints. There exists a sequence of combinatorial paths $\gamma_1=\alpha, \gamma_2,\ldots, \gamma_{n-1},\gamma_n=\beta$ such that, for every $1 \leq i \leq n-1$, $\gamma_{i+1}$ is obtained from $\gamma_i$ by flipping a square.*

Proposition 2 is Theorem 4.6 in Sageev's thesis *Ends of group pairs and non-positively curved cube complexes*, and Proposition 1 can be proved similarly. We deduce that:

Let $X$ be a CAT(0) cube complex and $Y \subset X$ a full subcomplex. Then $Y$ is convex if and only if it is connected and every square containing two consecutive sides in $Y$ lies entirely in $Y$.

Fix two vertices $a,b \in Y$. Because $Y$ is connected, there exists a combinatorial path in $Y$ between $a,b$. As a consequence of Proposition 1, $\alpha$ can be turned into a combinatorial geodesic $\gamma$ in $Y$. As a consequence of Proposition 2, every geodesic between $a$ and $b$ can be obtained from $\gamma$ by flipping squares, and so must lie in $Y$. We conclude that $Y$ is (combinatorially) convex.