• torbent

    (@torbentschechnegmailcom)


    Hello,
    I do not know if this is the right place to ask, but it’s a developer relevant question and usually I do not get an answer from a developer via the official WooCommerce support :/

    In the WooCommerce bookings plugin there is the option “Create Booking” in the backend to create a booking manually. I do need to enhance this booking mask with additionally fields.

    I use this action to create an input field:

    add_action(‘woocommerce_bookings_after_create_booking_page’, ‘custom_woocommerce_bookings_after_create_booking_page’);

    The problem is now, that the class-wc-bookings-create.php is called in the next step and there is this section:

    if ( ! empty( $_POST['create_booking'] ) ) {
    	$customer_id         = isset( $_POST['customer_id'] ) ? absint( $_POST['customer_id'] ) : 0;
    	$bookable_product_id = absint( $_POST['bookable_product_id'] );
    	$booking_order       = wc_clean( $_POST['booking_order'] );
    
    	if ( ! $bookable_product_id ) {
    		throw new Exception( __( 'Please choose a bookable product', 'woocommerce-bookings' ) );
    	}
    
    	if ( 'existing' === $booking_order ) {
    		$order_id      = absint( $_POST['booking_order_id'] );
    		$booking_order = $order_id;
    
    		if ( ! $booking_order || get_post_type( $booking_order ) !== 'shop_order' ) {
    			throw new Exception( __( 'Invalid order ID provided', 'woocommerce-bookings' ) );
    		}
    	}
    	/* Custom change */
    	$custom_booking_ref_id = $_POST['custom_booking_ref_id'];
    	/* Custom change End */
    
    	$step ++;
    	$product      = wc_get_product( $bookable_product_id );
    	$booking_form = new WC_Booking_Form( $product );
    
    } elseif ( ! empty( $_POST['create_booking_2'] ) ) {

    But here I do not have any possiblity to hook into that logic and do something with the value that I pass via the new input field.

    So I need to do something like this:

    /* Custom change */
    $custom_booking_ref_id = $_POST['custom_booking_ref_id'];
    /* Custom change End */

    Also there is no hook in the template of the second page “html-create-booking-page-2.php” that I can use. That is a bit weird, because why is there a hook on the first page when I can not use the enhancements I do there?

    And then I can use this value in the next steps as well, but there is no possibility to hook into it here to make the change also update safe, am I right? :/

    • This topic was modified 7 years, 8 months ago by torbent.
    • This topic was modified 7 years, 8 months ago by torbent.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Extend WooCommerce Bookings backend functionality?’ is closed to new replies.