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 );