Skip to content

Instantly share code, notes, and snippets.

@renjith-ph
Last active June 28, 2023 09:38
Show Gist options
  • Save renjith-ph/bf02655eb300779035862bb28ca8644c to your computer and use it in GitHub Desktop.
Save renjith-ph/bf02655eb300779035862bb28ca8644c to your computer and use it in GitHub Desktop.
Snippet to ignore the Booking period while displaying booking to date.
/* Snippet to ignore the Booking period while displaying booking to date.
Created at : 30 Jan 2019 PluginHive Plugins : https://www.pluginhive.com/plugins/
*/
add_filter( 'phive_booking_booked_price_details', 'remove_booking_period_time_from_booked_price_details',10,3 );
function remove_booking_period_time_from_booked_price_details( $booking_details,$product_id,$post_data ) {
$ignore_interval='true'; //set true to ignore booking period
$wp_date_time_format = get_option( 'date_format' ).' '.get_option( 'time_format' );
$interval_period = get_post_meta( $product_id, "_phive_book_interval_period", 1 );
$interval = get_post_meta( $product_id, "_phive_book_interval", 1 );
$interval_type = get_post_meta( $product_id, "_phive_book_interval_type", 1 );
if( $ignore_interval=='true' && (($interval_period == 'minute') || ($interval_period == 'hour')) && $interval_type == 'customer_choosen' ){
$to = wp_unslash($post_data['book_to']);
$to = date( 'Y-m-d H:i', strtotime($to) );
$output_date = DateTime::createFromFormat( 'Y-m-d H:i', esc_attr( $to ) );
$output_date = is_a( $output_date, 'DateTime' ) ? date_i18n( $wp_date_time_format, strtotime($output_date->format( "F j, Y H:i:s" )) ) : $to;
$booking_details['to_date']=$output_date;
}
return $booking_details;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment