Skip to content

Instantly share code, notes, and snippets.

@WillBrubaker
Created May 13, 2015 20:08
Show Gist options
  • Save WillBrubaker/d76f025f82aec6186863 to your computer and use it in GitHub Desktop.
Save WillBrubaker/d76f025f82aec6186863 to your computer and use it in GitHub Desktop.
Template override to remove WooCommerce Bookings resource cost indicator from dropdown select
<?php
extract( $field );
<p class="form-field form-field-wide <?php echo implode( ' ', $class ); ?>">
<label for="<?php echo $name; ?>"><?php echo $label; ?>:</label>
<select name="<?php echo $name; ?>" id="<?php echo $name; ?>">
<?php foreach ( $options as $key => $value ) : ?>
<?php
/*
The default file just echos out the value
this will modify that behaviour to match a pattern and replace that pattern with an empty string
it is echoed out below via preg_replace
*/
$pattern = '#\(\+<span class="amount">.*\)#';
$replacement = '';
?>
<option value="<?php echo $key; ?>"><?php echo preg_replace( $pattern, $replacement, $value ); ?></option>
<?php endforeach; ?>
</select>
</p>
@Drivingralle
Copy link

There is a filter called "woocommerce_bookings_resource_additional_cost_string" that allows to modify the string. Over writing the whole template removes the price from all "other" fields that use the type select. If that is the goal, this is the quickest way to change all outputs no matter the source (plugin).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment