fast_events_new_order

This action is called after the payment has been received and the customer has already received an email.

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

Parameters

$attr[‘order_ids’]

(int[]) Array of order id’s.

$attr[‘event_ids’]

(int[]) Array of event id’s.

$attr[‘id’]

(int) The id of the event. This value is read-only.

$attr[‘name’]

(string) The name of the person placing the order.

$attr[‘email’]

(string) The emailaddress of the person placing the order. This value is read-only.

$attr[‘total’]

(string) The total order value. For example 6.50. This value is read-only.

$attr[‘total_vat’]

(string) The total order VAT value. For example 2.50. This value is read-only.

$attr[‘fields’]

array of input fields.

  1. ‘name’ (string, case sensitive) The name of the input field.

  2. ‘value’ (string) The value of the input field.

$attr[‘tickets’]

array of ticket-types ordered.

  1. ‘name’ (string, case sensitive) The name of the ticket-type.

  2. ‘price’ (string) The ticket price. Example 6.25.

  3. ‘vat’ (string) VAT.

  4. ‘count’ (int) The number of tickets ordered.


Return

None


Changelog

Version

Description

1.0

Introduced.


Examples

Acumulus invoice

Send invoice data to Acumulus accounting. Put your contract information in the snippet and the right template name. Mind you, the snippet doesn’t do any error checking. You can find here the specification how to add an invoice.

 1<?php
 2function your_action_new_order( $attr ) {
 3  $xml  = '<?xml version="1.0" encoding="UTF-8"?>';
 4  $xml .= '<myxml>';
 5
 6  $xml .= '<format>xml</format>';
 7  $xml .= '<testmode>0</testmode>';
 8
 9  $xml .= '<contract>';
10  $xml .= '<contractcode>YOUR_CONTRACT_NUMBER</contractcode>';
11  $xml .= '<username>YOUR_USERNAME</username>';
12  $xml .= '<password>YOUR_PASSWORD</password>';
13  $xml .= '<emailonerror>YOUR_EMAIL</emailonerror>';
14  $xml .= '<emailonwarning>YOUR_EMAIL</emailonwarning>';
15  $xml .= '</contract>';
16
17  $xml .= '<customer>';
18  $xml .= '<fullname>' . $attr['name'] . '</fullname>';
19  $xml .= '<countrycode>NL</countrycode>';
20  $xml .= '<email>' . $attr['email'] . '</email>';
21  $xml .= '<invoice>';
22  $xml .= '<description>Etickets</description>';
23  $xml .= '<paymentstatus>2</paymentstatus>';
24  $xml .= '<template>YOUR_TEMPLATE_NAME</template>';
25
26  foreach ( $attr['tickets'] as $key => $value ) {
27    $xml .= '<line>';
28    $xml .= '<product>' . $value['name'] . '</product>';
29    $xml .= '<nature>Service</nature>';
30    $price_no_vat = (float) $value['price'] / ( 1 + ( (float) $value['vat'] / 100 ) );
31    $xml .= '<unitprice>' . number_format( $price_no_vat, 4, '.', '' ) . '</unitprice>';
32    $xml .= '<vatrate>' . $value['vat'] . '</vatrate>';
33    $xml .= '<quantity>' . $value['count'] . '</quantity>';
34    $xml .= '</line>';
35  }
36
37  $xml .= '<emailaspdf>';
38  $xml .= '<emailto>' . $attr['email'] . '</emailto>';
39  $xml .= '</emailaspdf>';
40
41  $xml .= '</invoice>';
42
43  $xml .= '</customer>';
44  $xml .= '</myxml>';
45
46  $ch = curl_init();
47  curl_setopt($ch, CURLOPT_URL, 'https://api.sielsystems.nl/acumulus/stable/invoices/invoice_add.php');
48  curl_setopt($ch, CURLOPT_POST, 1);
49  curl_setopt($ch, CURLOPT_SSLVERSION, 'CURL_SSLVERSION_TLSv1_2');
50  curl_setopt($ch, CURLOPT_POSTFIELDS, 'xmlstring=' . urlencode($xml));
51  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
52  curl_exec($ch);
53  curl_close($ch);
54}
55
56add_action( 'fast_events_new_order', 'your_action_new_order', 10, 1 );

Google Analytics ecommerce

Unleash the power of Google Analytics by adding this snippet. You get real-time access to a flood of data about your sales activity in reports and graphs. Install Google Analytics on your mobile and you will always have the data available at your fingertips. Don’t forget to enable e-commerce once you have defined your trackingcode.

 1<?php
 2function your_action_new_order_2( $attr ) {
 3  $cid = hash( 'adler32', $attr['email'] ) . '-1a05-49d7-b876-2b884d0f825b';
 4  $url = 'https://www.google-analytics.com/collect';
 5  $tid = 'UA-XXXXXXXXX-X';   // Put here your own trackingcode
 6
 7  wp_remote_post( $url, [
 8    'timeout' => 10,
 9    'body'    => [
10      'v'   => 1,
11      't'   => 'transaction',
12      'tid' => $tid,
13      'ds'  => 'Fast Events',
14      'cid' => $cid,
15      'ti'  => $attr['order_ids'][0],
16      'ta'  => $attr['event_ids'][0] . ' - ' . get_bloginfo( 'name' ),
17      'tr'  => $attr['total'],
18      'ts'  => '0.00',
19      'tt'  => $attr['total_vat'],
20      'cu'  => 'EUR'
21    ]
22  ]);
23
24  foreach ( $attr['tickets'] as $key => $value ) {
25    wp_remote_post( $url, [
26      'timeout' => 10,
27      'body'    => [
28        'v'   => 1,
29        't'   => 'item',
30        'tid' => $tid,
31        'ds'  => 'Fast Events',
32        'cid' => $cid,
33        'ti'  => $attr['order_ids'][0],
34        'in'  => $value['name'],
35        'ip'  => $value['price'],
36        'iq'  => $value['count'],
37        'ic'  => 'ic-' . $value['name'],
38        'iv'  => 'tickets',
39        'cu'  => 'EUR'
40      ]
41    ]);
42  }
43
44}
45
46add_action( 'fast_events_new_order', 'your_action_new_order_2', 10, 1 );