fast_events_invoice

This action is called if the invoice download URL is triggered. Download your own designed invoice possibly using an external financial accounting package. Make sure the right HTTP headers are generated to download a PDF file.

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

Parameters

$attr[‘id’]

(string) The unique order id.

$attr[‘event_id’]

(string) The unique order id.

$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.

$attr[‘invoice’]

array of invoice data.

  1. ‘company’ The name of the company. Can be empty,

  2. ‘vat’ The VAT-id of the company. Can be empty,

  3. ‘name’ (string) The name of the person.

  4. ‘street’ (string) The street address.

  5. ‘postcode’ (string) The postcode.

  6. ‘city’ (string) The city.

$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[‘created_at’]

(string) The datetime of the order.

$attr[‘event_name’]

(string) The name of the event.

$attr[‘event_date’]

(string) The date of the event.

$attr[‘event_date_format’]

(string) The date format of the event. The placeholders can be found here.


Return

None


Changelog

Version

Description

2.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.

Once you have submitted the data the return info will give you a token that can be used to retrieve the PDF. You can find here the specification how to retrieve the PDF. Generate the right download HTTP headers and ‘write’ the PDF to the standard output.

 1<?php
 2function your_action_invoice( $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['invoice']['name'] . '</fullname>';
19  $xml .= '<companyname1>' . $attr['invoice']['company'] . '</companyname1>';
20  $xml .= '<vatnumber>' . $attr['invoice']['vat'] . '</vatnumber>';
21  $xml .= '<address1>' . $attr['invoice']['street'] . '</address1>';
22  $xml .= '<postalcode>' . $attr['invoice']['postcode'] . '</postalcode>';
23  $xml .= '<city>' . $attr['invoice']['city'] . '</city>';
24  $xml .= '<countrycode>NL</countrycode>';
25  $xml .= '<email>' . $attr['email'] . '</email>';
26  $xml .= '<invoice>';
27  $xml .= '<description>Etickets</description>';
28  $xml .= '<paymentstatus>2</paymentstatus>';
29  $xml .= '<template>YOUR_TEMPLATE_NAME</template>';
30
31  foreach ( $attr['tickets'] as $key => $value ) {
32    $xml .= '<line>';
33    $xml .= '<product>' . $value['name'] . '</product>';
34    $xml .= '<nature>Service</nature>';
35    $price_no_vat = (float) $value['price'] / ( 1 + ( (float) $value['vat'] / 100 ) );
36    $xml .= '<unitprice>' . number_format( $price_no_vat, 4, '.', '' ) . '</unitprice>';
37    $xml .= '<vatrate>' . $value['vat'] . '</vatrate>';
38    $xml .= '<quantity>' . $value['count'] . '</quantity>';
39    $xml .= '</line>';
40  }
41
42  $xml .= '<emailaspdf>';
43  $xml .= '<emailto>' . $attr['email'] . '</emailto>';
44  $xml .= '</emailaspdf>';
45
46  $xml .= '</invoice>';
47
48  $xml .= '</customer>';
49  $xml .= '</myxml>';
50
51  $ch = curl_init();
52  curl_setopt($ch, CURLOPT_URL, 'https://api.sielsystems.nl/acumulus/stable/invoices/invoice_add.php');
53  curl_setopt($ch, CURLOPT_POST, 1);
54  curl_setopt($ch, CURLOPT_SSLVERSION, 'CURL_SSLVERSION_TLSv1_2');
55  curl_setopt($ch, CURLOPT_POSTFIELDS, 'xmlstring=' . urlencode($xml));
56  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
57  curl_exec($ch);
58  curl_close($ch);
59}
60
61add_action( 'fast_events_invoice', 'your_action_invoice', 10, 1 );