How to add dynamic fields to cart and checkout?
Hi Ray,
I am trying to add editable name and email address fields to the cart based on the quantity of the item ordered. Users register for a course by adding a class to the cart. Often the person doing the registering is not the person actually attending the class. To avoid confusion and work spent identifying the actual attendee, I want to collect the name and email of the attendee at registration so I can send course materials, reminders, certificates etc. to the correct person. It would also be helpful to register more than one person per class at a time.
What I am trying to do is have each class in the cart show name and email fields that match the quantity ordered. I was thinking that the information would then be saved in a session variable and inserted using multiple inserts to an order/class/attendee table in the db when PayPal returns the payment confirmation and the orderdetails are inserted into the db. I don't know whether this is a feasible way to do this or whether there is a better way to do this. If you can recommend a saner way, I'd be happy to do that.
Per information gleaned from the tutorials and this forum, I have tried to do adding custom fields with the AddToCart Buttons. I tried to add additional fields using php using both includes and show/hide behavior in the cart. I had some success using javascript, but was unable to successfully tie the quantity field to the created rows. The javascript disabled the cart buttons and also didn't repeat successfully for each item in the cart. I thought it would be easier for the correct number of input fields to load when the cart loaded rather than rely on the user to add and complete the correct number of fields. But maybe it is easier to tie the quantity ordered to the rows of attendees using validation?
I am tripping over my own ignorance, so any help and advice you can offer toward making this work will be much appreciated!