Table of Contents

bact_woocommerce_civicrm

This custom plugin handles much of the syncing of purchase data from WooCommerce into CiviCRM.

GitHub: https://github.com/ginkgostreet/bact_woocommerce_civicrm

Prerequisites and Configurations

  1. Ensure all required financial types are added to CiviCRM. These should be captured on prod-wp instance, and will endure a sandbox refresh. This is a one-time configuration for deployment.
    • Donation
    • Tickets
    • Flex Passes
    • OpenTickets Purchase
    • Tuition
  2. All products should have their CiviCRM Financial Type set appropriately
    • This is a MANUAL STEP when doing a full stage. We might automate it for deployment.
    • Ensure all WooCommerce products which are associated with OpenTickets events have their financial type set to 'Tickets' or 'Tuition'
    • This configuration needs to be set anytime a new product is created.
    • All products might as well have a WordPress category. The WP cat is not necessary for sync to work, but it will likely prove helpful for other tasks. This has been configured on prod-wp
  3. In CiviCRM, create a custom field group with the title OpenTickets (Participants) and the name “OpenTickets_Participants”, with a “Transaction” custom field.
    • One-time configuration
    • Added to prod-wp
  4. In CiviCRM, create a custom field group with the title OpenTickets (Contributions) and the name “OpenTickets_Contributions”, with a “Transaction” custom field.
    • One-time configuration
    • Added to prod-wp
  5. Please make sure “Non Attendees” participant role is created in CiviCRM db (Administrator > CiviEvent > Participant Roles > Add Participant Role)
    • One-time configuration
    • Added to prod-wp
  6. Please make sure “Edit Line Item Extension” is enabled (Administrator > System Settings > Extensions) for adding line item in contribution record.
    • One-time configuration
    • Added to prod-wp
    • Probably not needed for data synchronization, but required for editing line items in CiviCRM.

Expected Behaviors

  1. Participant for non attendee only sync if WooCommerce product associated with event having financial type set to 'Tickets' or 'Tuition'. (This statement is confusing needs to be clarified)
  2. A CiviCRM activity will be created if WooCommerce product having financial type set to “Flex Pass”. To-Do: does this activity type need to be created?

Technical Notes

Frontend Section (Directory Name: frontend )

File Name: frontend/class-bact-woocommerce-civicrm-purchase-details.php

  • add_action( 'woocommerce_payment_complete', array( $this, 'civicrm_sync_order_data' ), 10, 1 );
    • 'civicrm_sync_order_data' when order process payment completed then this function is called to sync the participant data while syncing data it will check if WooCommerce product associate with event having financial type set to 'Tickets' or 'Tuition' if financial type is classes and camp (Tuition) then we set the participant role id to non attendees. and for ticket it is an attendee.

Frontend Section (Directory Name: frontend )

File Name: frontend/class-bact-woocommerce-civicrm-sync-activity-record.php

  1. add_action( 'woocommerce_payment_complete', array( $this, 'civicrm_sync_activity_record' ), 10, 1 );
    • 'civicrm_sync_activity_record' when order process payment completed then this function is called to sync the activity data while syncing data it will check if WooCommerce product associate with event having financial type set to “Flex Passes” then only it will sync the activity data

Frontend Section (Directory Name: frontend )

File Name: frontend/class-bact-woocommerce-civicrm-sync-contrubution-record.php

  1. add_action( 'woocommerce_payment_complete', array( $this, 'civicrm_sync_contrubution_record' ), 20, 1 );
    • 'civicrm_sync_contrubution_record' when order process payment completed then this function is called to sync the contribution-record.