Documentation
- Getting started
- Basic settings
- Pro settings
- Product settings
- Manage bookings
- Localization
- Snippets
- Action and filter hooks
- Third-party plugins
add_filter( 'easy_booking_calculate_booking_price', '__return_false' );
add_filter( 'easy_booking_calculate_booking_price', 'wceb_calculate_booking_price', 10, 2 ); function wceb_calculate_booking_price( $calc, $_product ) { // Replace 'whatever' with Product ID if ( $_product->get_id() == 'whatever' ) { $calc = true; // Set true to enable price calculation, or false to disable. } return $calc; }
Example for a 5% discount 10 days before.
add_filter( 'easy_booking_one_date_price', 'wceb_early_bird_pricing', 40, 5 ); add_filter( 'easy_booking_two_dates_price', 'wceb_early_bird_pricing', 40, 5 ); function wceb_early_bird_pricing( $new_price, $product, $_product, $booking_data, $price_type ) { $current_date = time(); $start_date = strtotime( $booking_data['start'] ); // Get interval between current date and start date $interval = (int) ( $start_date - $current_date ) / 86400; if ( $interval >= 10 ) { $new_price *= 0.95; } return $new_price; }