you can use the product stock column of the products table for this.
where to put the code for this depends on the gateway you are using.
for most local checkout methods, this code can go on the confirm page. If you would like one on one help with accomplishing this, we can assist you in a screen sharing using a Premiere support appointment.