3 * Test Generated example demonstrating the Order.create API.
5 * Create order for participant
10 function order_create_example() {
13 'receive_date' => '2010-01-20',
14 'total_amount' => 300,
15 'financial_type_id' => 1,
16 'contribution_status_id' => 1,
17 'line_items' => array(
21 'price_field_id' => '2',
22 'price_field_value_id' => '2',
23 'label' => 'Price Field 1',
24 'field_title' => 'Price Field 1',
26 'unit_price' => '100',
27 'line_total' => '100',
28 'financial_type_id' => '4',
29 'entity_table' => 'civicrm_participant',
32 'price_field_id' => '2',
33 'price_field_value_id' => '3',
34 'label' => 'Price Field 2',
35 'field_title' => 'Price Field 2',
37 'unit_price' => '200',
38 'line_total' => '200',
39 'financial_type_id' => '4',
40 'entity_table' => 'civicrm_participant',
48 'register_date' => '2007-07-21 00:00:00',
49 'source' => 'Online Event Registration: API Testing',
56 $result = civicrm_api3('Order', 'create', $params);
58 catch (CiviCRM_API3_Exception
$e) {
60 $errorMessage = $e->getMessage();
61 $errorCode = $e->getErrorCode();
62 $errorData = $e->getExtraParams();
65 'error_message' => $errorMessage,
66 'error_code' => $errorCode,
67 'error_data' => $errorData,
75 * Function returns array of result expected from previous function.
80 function order_create_expectedresult() {
82 $expectedResult = array(
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',
98 'net_amount' => '300',
103 'cancel_reason' => '',
104 'receipt_date' => '',
105 'thankyou_date' => '',
107 'amount_level' => '',
108 'contribution_recur_id' => '',
110 'is_pay_later' => '',
111 'contribution_status_id' => '1',
113 'check_number' => '',
115 'creditnote_id' => '',
117 'revenue_recognition_date' => '',
118 'contribution_type_id' => '1',
123 return $expectedResult;
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
132 * You can see the outcome of the API tests at
133 * https://test.civicrm.org/job/CiviCRM-master-git/
135 * To Learn about the API read
136 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
138 * Browse the api on your own site with the api explorer
139 * http://MYSITE.ORG/path/to/civicrm/api
141 * Read more about testing here
142 * http://wiki.civicrm.org/confluence/display/CRM/Testing
144 * API Standards documentation:
145 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards