Add custom field to the check-out booking form
add_filter('sln.checkout.additional_fields',function(){ return array( 'custom_field_a'=> array( "label" => 'Custom field A', "type" => 'text', "width" => 'full', "default" => 'Your default value', "customer_profile" => true ), 'custom_field_b'=> array( "label" => 'Custom field B', "type" => 'textarea', "width" => 'half', "default" => 'Your default value' ), 'custom_field_c'=> array( "label" => 'Custom field C', "type" => 'select', "options" => array('option_a','option_b', 'option_c'), "width" => 'half', "default" => 'option_a' ), 'custom_field_d'=> array( "label" => 'Custom field D', "type" => 'checkbox' ), ); });
To add custom fields to the front-end check-out booking form copy and paste this code inside your theme functions.php file and change the fields according to your needs.
Fields types
These are the fields type available:
- Text
- Textarea
- checkbox
- select
Fields parameters
For each field you can specify these parameters:
- label
- type
- options ( if is a "select" type )
- width ( half, full, quarter )
- default value ( a text string for the text fields or 'true/false' for the checkbox )
- customer_profile ( 'true/false' ) for those fields that belong to the customer personal details
- customer_profile ( 'booking_hidden' ) if you don't want to show this fields inside the check-out booking form but only on the "Booking My Account" page inside the "Personal data" tab.
Fields management
The custom fields can be managed from "Settings > Check-out" section of Salon Booking settings