Save item in database based on condition

Situtation:

I have 2 prices in DB. When customer ticks the box, then the price will be A when not ticking price will be B.

As of now, i can show prices based on the condition, but i can’t save it in the field i have either A or B based on condition.

What i want: when box ticked, save price A to DB when not, save price B.

Thanks!