  In his pioneering work [Crelle's Journal, 1955], Eichler established the
theory of trace formulas for Brandt matrices of quaternion orders. From it he
derived a class number formula for Eichler orders in a totally definite
quaternion algebra $D$. Extending Eichler's work, Pizer [Crelle's Journal,
1973] proved a formula for the type number of Eichler orders in $D$. In this
paper, we extend their results to the norm one group of $D$. More precisely, we
present a class number formula for the norm one group of $D$ with respect to a
class of orders $\mathcal{O}$, called \emph{residually unramified orders},
which includes all Eichler orders. Our second result gives a formula for the
number of ideal classes in the spinor class of $\mathcal{O}$, which refines
Eichler's class number formula. It is worth mentioning that these class number
formulas not only depend on the genus of orders as Eichler and Pizer's
formulas, but also depend on the orders themselves. We introduce certain
auxiliary invariants in order to keep track of the global information on the
relationship between certain CM orders and $\mathcal{O}$, and use them to
describe our formulas. Both our class number formulas make use of the optimal
spinor selectivity theory for quaternion orders.
