Please consider leaving a donation if you appreciate this information. Lightning network now available
If you’re using customer selected resources with your WooCommerce Bookings products and those resources have costs then an indication of a price adjustment for those resources is output in the dropdown select.
You can remove those if you would like. There are a couple of ways to do that.
The first approach would be to remove that with a filter. Bookings provides a filter for the form fields called booking_form_fields which can be used to remove that. It is a bit tricky because the text that needs to be removed will be variable. My approach to this is to use a regular expression to match a pattern and replace that pattern with an empty string. Here’s a code snippet that will do this:
The other approach would be to use a template override. Bookings provides a way to override templates in a very similar fashion to the way that WooCommerce does it. You can read more about that here: Template Structure + overriding templates via a theme. The Main difference is that there is a different template override path for Bookings, i.e. wp-content/themes/YOUR-THEME/woocommerce-bookings the default template files can be found in wp-content/plugins/woocommerce-bookings/templates/. It is considered best practice to only override the templates necessary. For this case, the default template is called select.php and can be found in wp-content/plugins/woocommerce-bookings/templates/booking-form/ – again, I will use a regular expression to match and then replace a string of text – effectively removing the price indicator. You can see the edits needed by comparing the default template file to this:
If you would like to download, Register or Login
Not sure what to do with code snippets? See What Do I Do With These Code Snippets?
Please consider leaving a donation if you appreciate this information. Lightning network now available
Graham says
This seems to have broken since Woo 2.6+ as the span class=”amount” seems to be missing now?
Are you able to see if this code can be tweaked for the new format?
Many thanks.
will says
Change the pattern to something like this:
‘#\(\+\$.*\)#’;
vuewer says
This snippets works for me:
Add https://gist.github.com/WillBrubaker/b05bdf91da70a8a44b8f969bfcac694a to functions.php