How to reorder the fields on a WooCommerce Bookings product

By default, WooCommerce Bookings displays the field of a bookable product in the following order: Duration; Persons; Resource; and the Start Date.

Default Bookings Field Order

If you would like to reorder these fields, simply add the following code snippet in your child theme’s functions.php file:

/** 
 * A function to reorder the default display of fields on the WooCommerce Bookings form
 * Put this function in your theme's functions.php file
 */
function custom_order_booking_fields ( $fields ) {

	$reorder  = array();
	$reorder[] = $fields['wc_bookings_field_duration'];  // Duration
	$reorder[] = $fields['wc_bookings_field_resource'];  // Resource
	$reorder[] = $fields['wc_bookings_field_persons'];  // Persons
	$reorder[] = $fields['wc_bookings_field_start_date'];  // Calendar or Start Date

	return $reorder;
}
add_filter( 'booking_form_fields', 'custom_order_booking_fields');

By changing the line order in the function, you control the order in which they display on the front end of the bookable product.

Reordered Bookings Fields

Note: If you are using Person Types, this code will not work to display the different types.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s