Early bird pricing for Easy Booking (-5% if at least 11 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 ) {
// Get current date
$current_date = strtotime( date( 'Y-m-d' ) );
// Get start data
$start_date = strtotime( $booking_data['start'] );
// Get interval between current date and start date
$interval = absint( ( $start_date - $current_date ) / 86400 );
if ( $interval >= 11 ) {
$new_price *= 0.95;
}
return $new_price;
}
// Maybe display price detail
add_filter( 'easy_booking_booking_price_details', 'wceb_display_early_bird_discount', 10, 3 );
function wceb_display_early_bird_discount( $details, $product, $booking_data ) {
// Get current date
$current_date = strtotime( date( 'Y-m-d' ) );
// Get start data
$start_date = strtotime( $booking_data['start'] );
// Get interval between current date and start date
$interval = absint( ( $start_date - $current_date ) / 86400 );
if ( $interval >= 11 ) {
$details .= '<br />' . __( 'Price include a 5% discount', 'easy_booking' );
}
return $details;
}