Table of Contents

opentickets-civcrm-event-sync

Plugin that syncs OpenTickets Events and Event Dates to CiviCRM.

Roadmap feature: /roadmap/show-sync

Github: https://github.com/ginkgostreet/opentickets-civcrm-event-sync

Prerequisites and Configurations

  1. Create “OpenTickets Event” Campaign type in CiviCRM. This should already be captured on prod-wp instance, and will endure a sandbox refresh or deployment. This is a one-time configuration.
  2. Ensure all required event types are added to CiviCRM. These should already be captured on prod-wp instance, and will endure a sandbox refresh or deployment. This is a one-time configuration for deployment.
    • Conference
    • Exhibition
    • Fundraiser
    • Class Performance
    • Main Stage Performance
    • TVY Performance
    • Class
    • Subscription
    • Student Matinee
    • Student Performance
    • Drop-in Class
    • Rave
    • School Tour
    • Donor Event
  3. Set the CiviEvent type on all the OpenTickets events using the Event Type metabox drop-down, and then save the event to kick the opentickets-civcrm-event-sync plugin to do it's thing -- this should create CiviEvents and CiviCampaigns

Technical Notes

Admin Section (Directory Name: includes)

File Name: includes/class-campaign-type-events-meta-box-admin.php

In the above file we have "Campaign_Type_Events_Meta_Box_Admin" class in that we have added several functions and hooks to add the metabox in admin section of event

  1. add_action( 'add_meta_boxes', array( $this, 'ct_add_meta_box' ) );
    • To add the metabox in the admin section of the qsot_event custom post type for adding custom meta field to save the event type “_event_type”
  2. add_action( 'save_post', array( $this, 'save' ) );
    • When clicking on the publish or update button on event post the above function is called and it will save the selected event type form metabox and saved in the custom meta field “_event_type”.

Admin Section (Directory Name: includes)

File Name: includes/class-create-cv-campaign-admin.php

In the above file we have Create_CV_Campaign_Admin class in that we have added several functions and hooks to add create the campaign in CiviCRM database.

  1. add_action( 'save_post', array( $this, 'create_cv_campaign' ), 13, 2 );
    • This function is called when we click on the publish or update button of the event once this button is clicked then the function is executed it will create the campaign in civicrm database if campaign is already there then it will update the same campaign
    • For creating civicrm campaign we used following CiviCRM API:
    • $result = civicrm_api3(  'Campaign', 'create', ['id'               => $cv_campaign_id[0],
          'title'            => $ot_event_title . '-' . $start_date[0],
          'description'      => $ot_event_description,
          'start_date'       => $ot_event_start_date,
          'end_date'         => $ot_event_end_date,
          'campaign_type_id' => 'OpenTickets Event', 
          'status_id'        => 1,
          'is_active'        => $ot_event_status,
          'return'           => array( 'id' ),]);
  2. add_action( 'save_post', array( $this, 'delete_cv_campaign' ), 13, 2 );
    • This function is executed when we trash the event post it will deleted the open ticket parent event (i.e campaign in civicrm ) and the campaign in civicrm still exist it not deleted when open ticket event is deleted .

Admin Section (Directory Name: includes)

File Name: includes/class-create-cv-event-admin.php

In the above file we have Create_CV_Event_Admin class in that we have added several functions and hooks to add create the event in CiviCRM database.

  1. add_action( 'updated_post_meta', array( $this, 'create_cv_event' ), 10, 4 );
    • The above function is executed when we click on the publish or update button in the event sidebar section if event date is added in the event section then this function is created the event in the civicrm database
  2. add_action( 'save_post', array( $this, 'delete_cv_event' ), 13, 2 );
    • The above function is executed when we click trash link it will move the event in trash and update the civi event status to inactive status
  3. add_action( 'post_updated', array( $this, 'update_cv_event' ), 10, 3 );
    • The above function is executed when we click on the update button in the event sidebar section it will update the event in civicrm event if any updation is done in the open ticket event.