- This topic has 4 replies, 3 voices, and was last updated 2 years, 7 months ago by
Drew McManus.
-
AuthorPosts
-
July 9, 2018 at 10:02 am #128
Brian McDaniel
VEM UserI have another customization question. We want to dynamically populate 3 Gravity Form fields with lists of all occurrences (specifically date and venue of each occurrence) for 3 separate events. In short, this is a package deal combining 3 separate events that, when purchased as a single ticket item, receive a discounted price. So when they purchase this package, they will need to select the date and location for each event in a select field on the form. I know this is possible using Gravity Forms filters (https://docs.gravityforms.com/using-dynamic-population/) but need to know how I would grab the list of occurrences from each of the 3 events. I realize this will require custom coding, but is it something relatively simple you could point me in the right direction toward?
July 9, 2018 at 10:15 am #129Brian McDaniel
VEM UserHere is another link with explanation of how to populate a GF drop down (select) field: https://docs.gravityforms.com/dynamically-populating-drop-down-fields/
So I guess my question is regarding using get_posts to narrow down which event I am looking for specifically and then how to get the list of occurrences and print the date and venue for each occurrence within the GF filter that then populates the drop down.
Thanks!
July 9, 2018 at 11:51 am #131Aaron Overton
Lead DevIn your custom code (theme or plugin) you can create an instance of the VEM class and do a query. On it, you can set a context so that any filters you apply are specific to your custom code. (Context is an arbitrary string passed to our filters for that purpose.) Then you can filter the event where to just get you the specific event IDs you want. Finally, you can then retrieve the occurrences, which will also have their metadata already retrieved.
$vem3 = new VentureEventManager3(); $vem3->setContext('Iamtheawesome'); // Do any other pre-retrieve settings you might need vem3->retrieveDates(); $themThereDates = $vem3->getOccurrences(); add_filter('vem_events_where', 'doWhereAdjust', 10, 3); function doWhereAdjust($where, $archives, $context) { if ($context != 'Iamtheawesome') return; // Restrict your filtering to just your context // Adjust the $where array to include your where clause for just the list of specific events return $newWhere; }
I didn’t go test the above code snippet specifically, but I think it is right. I did check to make sure that the arguments on the filter are the correct number, order, and values. After the call to getOccurrences, $themThereDates should have all your dates for the three events and you can extra the relevant metadata from there.
If you need more help getting this done, talk to Drew about some custom dev time and I can put it into a custom plugin for you.
Blue skies,
-AaronJuly 9, 2018 at 12:35 pm #132Brian McDaniel
VEM UserThanks, Aaron. While I somewhat understand what you’ve shown here, I am still a bit more lost than I’d like to be. I’ll reach out to Drew to see about a quote.
July 9, 2018 at 8:36 pm #133Drew McManus
Lead DevMany thanks Brian, I’ll keep an eye out for your note.
-
AuthorPosts
- You must be logged in to reply to this topic.