post_parent ) ) { return; } echo '
'; echo '

' . esc_html__( 'Booking', 'abogo-booking' ) . '

'; woocommerce_wp_select( array( 'id' => 'abfw_dates_' . $loop, 'name' => 'abfw_dates[' . $loop . ']', 'label' => __( 'Dates to choose', 'abogo-booking' ), 'wrapper_class' => 'form-row form-row-first', 'options' => array( '' => __( 'Same as the product', 'abogo-booking' ), 'one' => __( 'One date', 'abogo-booking' ), 'two' => __( 'Arrival and departure', 'abogo-booking' ), ), 'value' => get_post_meta( $variation->ID, '_abfw_dates', true ), ) ); woocommerce_wp_select( array( 'id' => 'abfw_mode_' . $loop, 'name' => 'abfw_mode[' . $loop . ']', 'label' => __( 'Charged by', 'abogo-booking' ), 'wrapper_class' => 'form-row form-row-last', 'options' => array( '' => __( 'Same as the product', 'abogo-booking' ), 'nights' => __( 'Night', 'abogo-booking' ), 'days' => __( 'Day', 'abogo-booking' ), ), 'value' => get_post_meta( $variation->ID, '_abfw_mode', true ), ) ); $numbers = array( 'duration' => __( 'Booking duration', 'abogo-booking' ), 'min' => __( 'Minimum duration', 'abogo-booking' ), 'max' => __( 'Maximum duration', 'abogo-booking' ), 'first' => __( 'First available date', 'abogo-booking' ), 'last' => __( 'Last available date', 'abogo-booking' ), ); $position = 0; foreach ( $numbers as $key => $label ) { woocommerce_wp_text_input( array( 'id' => 'abfw_' . $key . '_' . $loop, 'name' => 'abfw_' . $key . '[' . $loop . ']', 'label' => $label, 'wrapper_class' => 0 === $position % 2 ? 'form-row form-row-first' : 'form-row form-row-last', 'type' => 'number', 'placeholder' => __( 'Same as the product', 'abogo-booking' ), 'custom_attributes' => array( 'min' => '0', 'step' => '1', ), 'value' => get_post_meta( $variation->ID, '_abfw_' . $key, true ), ) ); ++$position; } /** * Fires at the end of the booking rules of a variation, so an extension can add its own. * * @since 1.1.0 * @param int $loop Index of the variation in the list. * @param \WP_Post $variation Variation post. */ do_action( 'abfw_variation_panel', $loop, $variation ); echo '
'; } /** * Save the fields of one variation. * * @since 1.0.0 * @param int $variation_id Variation being saved. * @param int $loop Index of the variation in the posted list. */ public function save( $variation_id, $loop ) { // WooCommerce checked the nonce of the product screen before firing this. // phpcs:disable WordPress.Security.NonceVerification.Missing foreach ( self::KEYS as $key ) { $posted = isset( $_POST[ 'abfw_' . $key ][ $loop ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'abfw_' . $key ][ $loop ] ) ) : ''; if ( '' === $posted ) { delete_post_meta( $variation_id, '_abfw_' . $key ); continue; } $value = in_array( $key, array( 'dates', 'mode' ), true ) ? $posted : max( 0, (int) $posted ); update_post_meta( $variation_id, '_abfw_' . $key, $value ); } // phpcs:enable WordPress.Security.NonceVerification.Missing } }