I'm including a form within the template for an existing custom post type on a non-profit site. The custom post type will have a custom field for sponsors with a value of 0-5, and I want to both get that value for display in the form, as well as update the field when the form is submitted.
For instance, a visitor to the site might see that there is 1 sponsor slot already taken, and they want to offer two more. I'd like the form to:
1) Query the field to properly display how many sponsorships are available. (In this case, only 4, so it would display a drop down with 1-4.)
2) Assuming the user selects the number 2, for two sponsorships, the form would the update the custom field to add 2 to it, so that it would now display that 3 sponsorships have been taken for the next user.
3) To possibly confuse the issue, the number of sponsorships should be taken from a product quantity as it will also be processing their payment.
Is this doable? And if so, any pointers on the proper code?