Nicola Mustone

Happiness Lead @ Automattic



Change The Booking Form Strings

WooCommerce Bookings shows a form to book the product on its single page. The form includes a calendar and it may include other fields like persons and resources, based on the product configuration.

Also, always based on the product configuration, the form will show different strings to the user to communicate the product availability or other things.

How do you change these form strings? They are not always right, your product may require a different string.

As always, there’s a snippet!

Hands On The Code!

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


add_filter( 'booking_form_params', 'change_booking_form_params' );
function change_booking_form_params( $params ) {
$params['i18n_date_unavailable' = 'This date is unavailable';
$params['i18n_date_fully_booked'] = 'This date is fully booked and unavailable';
$params['i18n_date_partially_booked'] = 'This date is partially booked – but bookings still remain';
$params['i18n_date_available'] = 'This date is available';
$params['i18n_start_date'] = 'Choose a Start Date';
$params['i18n_end_date'] = 'Choose an End Date';
$params['i18n_dates'] = 'Dates';
$params['i18n_choose_options'] = 'Please select the options for your booking above first';
return $params;
}

view raw

functions.php

hosted with ❤ by GitHub

This code already includes all the default form strings used by WooCommerce Bookings. You can change any of them, and remove the ones that you don’t want to change, by deleting the entire line.

You can also actually leave them in the file, but I suggest not to, especially if your site language is not English. Leaving them there in English will cause localization issues since WooCommerce Bookings will not find those form strings for localization.

Advertisements

Subscribe to This Blog

Receive new articles from this blog directly in your inbox! No spam guaranteed!

Join 651 other subscribers

Contribute to Improving This Blog

Did you enjoy this article? Was it helpful? Contribute to help me write more articles! The funds collected from this blog are reinvested directly into improving my skills or the blog so that I can provide more and better content!

One-Time
Monthly
Yearly

Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount

€5.00
€15.00
€100.00
€5.00
€15.00
€100.00
€5.00
€15.00
€100.00

Or enter a custom amount


Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly
Advertisements

More Posts That You Might Like…


2 responses to “Change The Booking Form Strings”

  1. Hello . it was great. Thank you from your site

  2. Hi! Do have a snippet to hide the price total on the booking form? I use the extra product options plugin that calculates the total price based on options, and I need to remove the price shown by the bookings plugin (which in my case shows 0).
    Thanks!

Leave a Reply

Advertisements

Categories

Newsletter

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Join 651 other subscribers

About The Author

Hi, I’m Nico! Support Lead at Automattic, championing WordPress.com & WooCommerce. Off-duty, I’m at Elemental Beacon, leading epic D&D adventures. Let’s connect, whether it’s about WordPress or a quest!

Advertisements

Don't Miss a Thing!

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Join 651 other subscribers

Continue Reading

%d bloggers like this: