Hi, This is what’s included
/*
* Add custom fields to each add to cart form.
*/
add_filter( 'mt_custom_fields', 'create_custom_fields', 10, 3 );
function create_custom_fields( $array ) {
// Other fields: sanitize callback; input type; input values; display_callback
$array['food_pref'] = array(
'title'=>"Food preferences",
'sanitize_callback'=>'sanitize_callback',
'display_callback'=>'display_callback',
'input_type'=>'select',
'input_values'=>array( 'I eat all ', 'No meat ', 'No Fish ', 'Vegan ' ),
'context'=> '309'
);
/**
* Add a second custom field by adding more values to the array
*
*/
$array['other'] = array(
'title'=>"Other or allergy",
'sanitize_callback'=>'sanitize_callback',
'display_callback'=>'display_callback',
'input_type'=>'textarea',
'context'=> '309'
);
/**
* Add a third custom field by adding more values to the array
*
*/
$array['presence'] = array(
'title'=>"Will you miss some of the nights? (which one)",
'sanitize_callback'=>'sanitize_callback',
'display_callback'=>'display_callback',
'input_type'=>'textarea',
'context'=> '309'
);
return $array;
}
/* This display callback is used to format the saved data. $context is either 'payment' or 'cart', depending on whether it's appearing in an admin payment record or in the user's cart. */
function display_callback( $data, $context='payment' ) {
return urldecode( $data );
}
/* This sanitize callback is used to sanitize the data before it's saved to the DB */
function sanitize_callback( $data ) {
return esc_sql( $data );
}