Posted on

Change the fields order in Bookings form

WooCommerce Bookings has a form which allows your customers to choose the duration of their booking, the number of persons to book, the date and resources.
All the fields are shown in a specific order by default, which is

  1. Duration (if not fixed)
  2. Number of persons
  3. Resources (if not automatically assigned)
  4. Calendar

Do you need to change this order? Great, here is a snippet for you then.

Open the file functions.php located in wp-content/themes/your-theme-name/ and add this code at the end of the file:

From the line 2 to 5 it copies the default values of each field. Then from line 7 it begins to reorder the fields and returns the array of fields using the new order.
In this example, the first field will be the calendar, the second the resource, then the duration and at last the persons field.

You can obviously change this order by moving the lines from 8 to 11 up and down as you need.

Note: This is only a basic example. If you use persons type or multiple resources the code may change.

9 thoughts on “Change the fields order in Bookings form

  1. Hi Nicola!!

    Thanks of an amazing blog, tried this but it spat a whole load of errors out at us, has anything changed which would prevent this working that you know?

    1. Hi,
      not that i know, but i might change if you are using multiple resources or person types.

      So be sure to debug $fields and check what’s in there.

  2. Hey Nicola – great blog… I have recently been following along, and came upon this post about bookings… I’m currently attempting to show the booking calendar on the cart page (to make any last minute changes)… do you have any insight on how to do this?

    1. Hi Ray,
      that would be quite hard to do. Definitely not supported in the core. I’d suggest to hire an expert to make this change since it’s not something that can be explained easly on a blog, sorry 🙁

  3. Hi thanks for this post.

    Do you know how to change the order of the Calendar days from Monday – Sunday to Sunday to Monday?

    Thanks in advance,
    Roselle

    1. Hi Roselle,
      You need to change the first day of the week in Settings > General.

  4. not working for person types , any help ?

  5. Hey Nicola!! Nice blog and thanks for you post. I have one question about bookings. Is it possible by default to have 2 persons and keep the option of select 1 person? Because if you select minimun 1 person and maximum 3, by default appears 1. I will like to have 2 by default.

    Thanks in advance!!

    1. Thanks, Samuel!

      I checked for the default value of the Persons field, it’s not easily editable.

Leave a Reply
You have to agree to the comment policy.