How to add additional fields at checkout
Last Updated: October 23, 2024
Where do I put this code? — in functions.php file in your theme (recommended) or in any plugin folder index php file.
Code 1: Include new field in settings
add_filter('evotx_checkout_additional_fields_settings','evotx_2',10,1);
function evotx_2($fields){
$fields['business'] = __('Business Name','evotx');
// you can add other fields like this similarly
return $fields;
}
Code 2: Include at checkout stage
The below code will make sure the new field will show in the checkout page for woocommerce.
add_filter('evotx_additional_ticket_info_fields', 'evotx_1', 10,1); function evotx_1($fields){ // additonal field code block $fields['business'] = array( 'type'=>'text', 'label'=> evo_lang('Business Name'), 'required'=> false, ); // you can use same code block for more fields return $fields; }
Code 3: Show the save information
There are several places we need to show the ticket holder custom data. First place is ticket holder details on Woocommerce emails and View Attendees sections.
add_filter('evotx_get_attendees_for_event', 'evotx_3',10, 3); function evotx_3($arr, $event_id, $_th){ if(!isset($_th['business'])) return $arr; $arr['oD']['business'] = $_th['business']; // the above 2 lines can be used for all other new fields return $arr; }
Code 4: Show in the confirmation email
Below code will make sure the custom additional data collected is displayed in the confirmation email as well. EventON Tickets v 2.3.3 is needed for this.
add_filter('evotx_confirmation_email_additional_data_array','evotx_4', 10, 4);
function evotx_4( $array, $_this_ticket , $TIX_CPT, $EVENT ){
if( empty( $_this_ticket['oD']['business'] )) return $array;
$array['business'] = array(
'label'=> evo_lang('Business Name'),
'value'=> $_this_ticket['oD']['business']
);
return $array;
}
Did this article help you?
Event Tickets Addon Buy Now