This makes no sense
else {
if (total > 0)
total = total - price;
}
That else makes NO sense at all, so if the checkbox is unchecked, you subtract. So if the first checkbox is checked it will make total > 0 and all checkboxes are unchecked, you start subtracting their values until it is zero.
That else check does not belong there.