Default options of Booking when creating new product
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Enabling the required option for new product. | |
function bkap_enable_option_for_new_product( $booking_checked, $duplicate_of, $booking_settings ) { | |
if ( '' === $booking_settings ) { // enable booking option for new product. | |
$booking_checked = 'checked'; | |
} | |
return $booking_checked; | |
} | |
add_filter( 'bkap_enable_booking', 'bkap_enable_option_for_new_product', 10, 3 ); | |
add_filter( 'bkap_inline_calendar_option', 'bkap_enable_option_for_new_product', 10, 3 ); | |
// Setting default Booking type to Duration Based Time | |
function bkap_default_booking_type_for_new_product( $booking_type, $duplicate_of, $booking_settings ){ | |
if ( '' === $booking_settings ) { // enable booking option for new product. | |
$booking_type = 'duration_time'; | |
} | |
return $booking_type; | |
} | |
add_filter( 'bkap_booking_type', 'bkap_default_booking_type_for_new_product', 10, 3 ); | |
// Setting Minimum Duration to 4. | |
function bkap_minimum_duration( $min, $product_id, $booking_settings ) { | |
if ( '' === $booking_settings ) { // enable booking option for new product. | |
$min = 4; | |
} | |
return $min; | |
} | |
add_filter( 'bkap_minimum_duration', 'bkap_minimum_duration', 10, 3 ); | |
// inline script via wp_print_scripts. | |
function bkap_print_scripts() { | |
if ( 'product' == get_post_type() ) { | |
?> | |
<script> | |
jQuery( document ).ready( function () { | |
if( jQuery('#bkap-booking-type' ).length > 0 ) { | |
jQuery('#bkap-booking-type' ).trigger( 'change' ); | |
} | |
}); | |
</script> | |
<?php | |
} | |
} | |
add_action( 'wp_print_scripts', 'bkap_print_scripts' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment