fast_events_scan_ticket

This action is called after the ticket has been scanned. Be careful not to include code that has a long execution time as it directly influences the response time of the mobile scan app.

1<?php
2function your_action_scan_ticket( $attr, $scans ) {
3  // Do what you need to do
4}
5
6add_action( 'fast_events_scan_ticket', 'your_action_scan_ticket', 10, 2 );

Parameters

$attr[‘order_id’]

(int) The unique order id.

$attr[‘qrcode’]

(string) The unique qrcode of the ticket.

$attr[‘status’]

(boolean) Scan result is true or false. If false, $attr[‘date’] and $attr[‘location’] will contain the date and location where the ticket was already scanned.

$attr[‘event’]

(string) The name of the event. Comes from Basics tab.

$attr[‘type’]

(string) The name of the ticket. Comes from Tickets tab.

$attr[‘name’]

(string) The name of the person who placed the order.

$attr[‘email’]

(string) The emailaddress of the person who placed the order.

$attr[‘level’]

(int) 0 = entrance scan, 1 = staged scan, 9 = exit scan.

$attr[‘date’]

(string) The date when the ticket was scanned. Format YYYY-MM-DD HH:MM:SS.

$attr[‘location’]

(string) The location the ticket was scanned.

$attr[‘scans’]

(array) Scans ordered by ‘scan_date

  1. ‘level’ (int) 0 = Entry scan, 1 = staged scan, 9 = exit scan

  2. ‘scan_date’ (string) Uses the date format defined in ‘Scan -tab‘.

  3. ‘scan_location’ (string) The location of the scan.


Return

None


Changelog

Version

Description

1.0

Introduced.

1.9.3

Added order_id and qrcode.


Examples

Google Analytics scan event

All scan data is entered in Google Analytics, so you get valuable real-time insight into the scanning activities. Install Google Analytics on your mobile and you will always have the scan-data available at your fingertips.

 1<?php
 2function your_action_scan_ticket( $attr ) {
 3  wp_remote_post( 'https://www.google-analytics.com/collect', [
 4    'timeout' => 3,
 5    'body'    => [
 6      'v'   => 1,
 7      't'   => 'event',
 8      'tid' => 'UA-XXXXXXXXX-X',  // Put your own tracking ID here
 9      'ds'  => 'Fast Events',
10      'cid' => hash( 'adler32', $attr['email'] ) . '-1a05-49d7-b876-2b884d0f825b',
11      'ec'  => 'scan-' . ( true === (bool) $attr['status'] ? '1' : '0' ),
12      'ea'  => $attr['location'] . ' - ' . $attr['type'],
13      'el'  => $attr['type'],
14      'ev'  => 1
15    ]
16  ]);
17}
18
19add_action( 'fast_events_scan_ticket', 'your_action_scan_ticket', 10, 1 );

Send “Thank you” email after exit scan

Send a “Thank you for visiting” email to users who pass the exit scan (level = 9). You can of course trigger on another level or any other attribute. Use the internal function fe_helper_func()->send_email() to send an email which will use the credentials defined in the plugin settings.

 1<?php
 2function your_action_scan_ticket( $attr, $scans ) {
 3  if ( 9 === $attr['level'] ) {
 4    $message = '<p>Dear ' . $attr['name'] . ',</p>' .
 5      '<p>Thank you for visiting our event. Hope to see you <b>next</b> year</p>' .
 6      '<p>Vintage Vinyl Open Air 2019 team</p>';
 7    fast_events_helper_func()->send_email( $attr['email'], "Thank you for visiting Vintage Vinyl Open Air 2019", $message );
 8  }
 9}
10
11add_action( 'fast_events_scan_ticket', 'your_action_scan_ticket', 10, 2 );

Send “Thank you” email with detailed scan info

Send a “Thank you for visiting” email to users who pass the exit scan (level = 9) and also email them the detailed info on when they passed all checkpoints during the bicycle tour. You can of course trigger on another level or any other attribute. Use the internal function fe_helper_func()->send_email() to send an email which will use the credentials defined in the plugin settings.

 1<?php
 2function your_action_scan_ticket( $attr, $scans ) {
 3  if ( 9 === $attr['level'] ) {
 4    $message = '<p>Dear ' . $attr['name'] . ',</p>' .
 5      '<p>Thank you for participating in our bicycle tour. Hope to see you <b>next</b> year.' .
 6      'Below are the times when you passed the checkpoints.</p><table>';
 7    foreach( $scans as $key => $value ) {
 8      $message .= '<tr><td>' . $value->scan_date . '</td><td>' . $value->scan_location . '</td></tr>';
 9    }
10    $message .= '</table><p>The National bicycle tour team</p>';
11    fast_events_helper_func()->send_email( $attr['email'], "Thank you for participating in our bicycle tour", $message );
12  }
13}
14
15add_action( 'fast_events_scan_ticket', 'your_action_scan_ticket', 10, 2 );