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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
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.
Leave a Reply