Thank you for reporting, we will resolve it shortly
Q.
Soaps do not work in hard water containing calcium and magnesium ions because
Chemistry in Everyday Life
Solution:
$Ca^{2+}$ and $Mg^{2+}$ ions form insoluble calcium and magnesium soaps respectively when sodium or potassium soaps are dissolved in hard water.
$\underset{\text{Soap}}{2C_{17}H_{35}COOHNa}+CaCl_{2} \to 2NaCl
+ \underset{\text{Insoluble calcium stearate (soap) }}{(C_{17}H_{35}COO)_2Ca}$
These insoluble soaps separate as scum in water and are useless as cleansing agent.