Documentation
- Getting started
- Basic settings
- Pro settings
- Product settings
- Manage bookings
- Localization
- Snippets
- Action and filter hooks
- Third-party plugins
Add these snippets to your child theme’s functions.php file or use a plugin like Code snippets. Don’t add code directly to the parent theme’s functions.php file as it will be overridden by updates.
add_action( 'easy_booking_after_update_product_stock_data', 'wceb_share_availability', 10, 4 ); function wceb_share_availability( $item, $product_id, $_product_id, $booked_dates ) { // Replace with product IDs you want to share availability $share = array( '1', '2', '3' ); if ( in_array( $_product_id, $share ) ) { foreach ( $share as $index => $id ) { if ( $_product_id != $id ) { update_post_meta( $id, '_wceb_product_booked_dates', $booked_dates ); } } } } add_filter( 'easy_booking_get_bookings', 'wceb_get_shared_availability', 10, 1 ); function wceb_get_shared_availability( $bookings ) { // Replace with product IDs you want to share availability $share = array( '1', '2', '3' ); if ( ! empty( $bookings ) ) foreach ( $bookings as $booking ) { $product_id = $booking['product_id']; if ( in_array( $product_id, $share ) ) { foreach ( $share as $index => $id ) { if ( $product_id != $id ) { $bookings[] = array( 'product_id' => $id, 'start' => $booking['start'], 'end' => $booking['end'], 'qty' => $booking['qty'] ); } } } } return $bookings; }
add_filter( 'easy_booking_product_unavailability_period', 'wceb_unavailability_period', 10, 3 ); function wceb_unavailability_period( $unavailability_period, $product_id, $variation_id ) { if ( $product_id == '93' ) { $unavailability_period = 2; } return $unavailability_period; }