I’ve had no problem hooking up the Woocommerce Tickets module and inserting my own constant custom checkout fields via this documentation:
http://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/
However, I have a few custom checkout fields I’d like to conditionally add based on the type of event. For example, I’d like to include a “Dietary Restrictions” field for events involving food.
I’ve concocted one way to maybe do this, but I wanted to see if maybe I was taking the long way around:
Admin Step 1) Enter an event and a corresponding ticket.
Admin Step 2) Find that ticket under products and categorize it as “Includes Food”.
Developer Step 1) In functions.php, add a field “Dietary Restrictions” with the class “food”.
Developer Step 2) In the css, set class “food” to display:none.
Developer Step 3) On the checkout form (woocommerce/form-billing), access the Woocommerce cart object to retrieve the product id(s).
Developer Step 4) Loop through the product ids, retrieving their Product Categories to see if any are classified as “Includes Food”.
Developer Step 5) If so, set class “food” to display:block.
It seems a little circuitous for both the admin and the developer, and it also modifies a core Woocommerce file, so I’m hoping someone has a better suggestion. Thanks!