Merge pull request #9670 from johanv/CRM-19869-pdf_table_header_issue
[civicrm-core.git] / api / v3 / examples / Order / CreateOrderParticipant.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Order.create API.
4 *
5 * Create order for participant
6 *
7 * @return array
8 * API result array
9 */
10 function order_create_example() {
11 $params = array(
12 'contact_id' => 11,
13 'receive_date' => '2010-01-20',
14 'total_amount' => 300,
15 'financial_type_id' => 1,
16 'contribution_status_id' => 1,
17 'line_items' => array(
18 '0' => array(
19 'line_item' => array(
20 '2' => array(
21 'price_field_id' => '2',
22 'price_field_value_id' => '2',
23 'label' => 'Price Field 1',
24 'field_title' => 'Price Field 1',
25 'qty' => 1,
26 'unit_price' => '100',
27 'line_total' => '100',
28 'financial_type_id' => '4',
29 'entity_table' => 'civicrm_participant',
30 ),
31 '3' => array(
32 'price_field_id' => '2',
33 'price_field_value_id' => '3',
34 'label' => 'Price Field 2',
35 'field_title' => 'Price Field 2',
36 'qty' => 1,
37 'unit_price' => '200',
38 'line_total' => '200',
39 'financial_type_id' => '4',
40 'entity_table' => 'civicrm_participant',
41 ),
42 ),
43 'params' => array(
44 'contact_id' => 11,
45 'event_id' => 1,
46 'status_id' => 1,
47 'role_id' => 1,
48 'register_date' => '2007-07-21 00:00:00',
49 'source' => 'Online Event Registration: API Testing',
50 ),
51 ),
52 ),
53 );
54
55 try{
56 $result = civicrm_api3('Order', 'create', $params);
57 }
58 catch (CiviCRM_API3_Exception $e) {
59 // Handle error here.
60 $errorMessage = $e->getMessage();
61 $errorCode = $e->getErrorCode();
62 $errorData = $e->getExtraParams();
63 return array(
64 'is_error' => 1,
65 'error_message' => $errorMessage,
66 'error_code' => $errorCode,
67 'error_data' => $errorData,
68 );
69 }
70
71 return $result;
72 }
73
74 /**
75 * Function returns array of result expected from previous function.
76 *
77 * @return array
78 * API result array
79 */
80 function order_create_expectedresult() {
81
82 $expectedResult = array(
83 'is_error' => 0,
84 'version' => 3,
85 'count' => 1,
86 'id' => 1,
87 'values' => array(
88 '1' => array(
89 'id' => '1',
90 'contact_id' => '11',
91 'financial_type_id' => '1',
92 'contribution_page_id' => '',
93 'payment_instrument_id' => '4',
94 'receive_date' => '20100120000000',
95 'non_deductible_amount' => '',
96 'total_amount' => '300',
97 'fee_amount' => 0,
98 'net_amount' => '300',
99 'trxn_id' => '',
100 'invoice_id' => '',
101 'currency' => 'USD',
102 'cancel_date' => '',
103 'cancel_reason' => '',
104 'receipt_date' => '',
105 'thankyou_date' => '',
106 'source' => '',
107 'amount_level' => '',
108 'contribution_recur_id' => '',
109 'is_test' => '',
110 'is_pay_later' => '',
111 'contribution_status_id' => '1',
112 'address_id' => '',
113 'check_number' => '',
114 'campaign_id' => '',
115 'creditnote_id' => '',
116 'tax_amount' => '',
117 'revenue_recognition_date' => '',
118 'contribution_type_id' => '1',
119 ),
120 ),
121 );
122
123 return $expectedResult;
124 }
125
126 /*
127 * This example has been generated from the API test suite.
128 * The test that created it is called "testAddOrderForParticipant"
129 * and can be found at:
130 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/OrderTest.php
131 *
132 * You can see the outcome of the API tests at
133 * https://test.civicrm.org/job/CiviCRM-master-git/
134 *
135 * To Learn about the API read
136 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
137 *
138 * Browse the api on your own site with the api explorer
139 * http://MYSITE.ORG/path/to/civicrm/api
140 *
141 * Read more about testing here
142 * http://wiki.civicrm.org/confluence/display/CRM/Testing
143 *
144 * API Standards documentation:
145 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
146 */