Support » Plugin: WooCommerce » Default number of persons in woocommerce Bookings

  • Resolved samuelacera

    (@samuelacera)


    Hi there!

    I will like to know how it’s possible to change the default numbers of persons in any product of woocommerce bookings.

    By default, if you select the option select number of persons the number is the minimum allowed. I will like by default to have 2 persons, not the minimum (1).

    Thanks in advance. I think this could be useful for many users of this plugin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Samuel,

    I’ve been trying to find some kind of filter to modify the default value used in persons field, but I’ve not found any. The most direct way to change that seems to be by override the number.php template.

    Copy the file from

    wp-content/plugins/woocommerce-bookings/templates/booking-form/number.php

    to

    wp-content/themes/your-theme/woocommerce-bookings/booking-form/number.php

    and edit the file number.php under your theme:

    <?php extract( $field ); ?>
    <?php
    if( $field['name'] == 'wc_bookings_field_persons' ) {
        $defaut_value = 2;
    } else {
        $defaut_value = ( ! empty(  $field['min'] ) ) ? $field['min'] : 0;
    }
    ?>
    <p class="form-field form-field-wide <?php echo implode( ' ', $class ); ?>">
    	<label for="<?php echo $name; ?>"><?php echo $label; ?>:</label>
    	<input
    		type="number"
    		value="<?php echo $defaut_value; ?>"
    		step="<?php echo ( isset( $step ) ) ? $step : ''; ?>"
    		min="<?php echo ( isset( $min ) ) ? $min : ''; ?>"
    		max="<?php echo ( isset( $max ) ) ? $max : ''; ?>"
    		name="<?php echo $name; ?>"
    		id="<?php echo $name; ?>"
    		/> <?php echo ( ! empty( $after ) ) ? $after : ''; ?>
    </p>
    • This reply was modified 6 months, 1 week ago by  cybmeta.

    It’s alive!! It’s alive!! Thanks, it is working!!

    Resolved!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Default number of persons in woocommerce Bookings’ is closed to new replies.