Join our new community forum for support & discussion

Join Now

Home Support Themes RentalHive Booking Note Required – Snippet

Booking Note Required – Snippet

  • Author
    Posts
  • Mishoo

    Hey @ihor and team,

    quick snippet question:

    would like to set Booking Note during Vendor registration REQUIRED.

    Tried this snippet but I think I am using the wrong hook:

    `// makes booking note field required
    add_filter(
    ‘hivepress/v1/models/listing_submit’,
    function( $model ) {
    $model[‘fields’][‘booking_note’][‘required’] = true;

    return $model;
    },
    1000
    );

    Hope you can help!

    Thanks in advance!

    yevhen developer

    If you mean vendor registration form then please try this PHP snippet

    add_filter(
    	'hivepress/v1/forms/user_update_profile',
    	function( $form ) {
                    if(isset($form['fields']['booking_note'])){
                        $form['fields']['booking_note']['required'] = true;
                    }
    
    		return $form;
    	},
    	1000
    );
    Mishoo

    @yevhen many thanks! I’ve saved it to my PHP Snippets Bank! 🙂

    However, I am not sure if we are speaking of the same “note”.

    I need to access the BOOKING NOTE (OPTIONAL) Attribute on the following page:
    https://domain.com/submit-listing/details/

    What I am looking for is one of the following three options regarding this attribute :

    • Show BOOKING NOTE after successful payment (best solution)
    • Hide booking note completely
    • Require BOOKING NOTE
    • Thank you so much.

    yevhen developer

    Please try this PHP snippet instead. It will make booking note field required

    add_filter(
    	'hivepress/v1/forms/listing_update',
    	function( $form ) {
                    if(isset($form['fields']['purchase_note'])){
                        $form['fields']['purchase_note']['required'] = true;
                    }
    
    		return $form;
    	},
    	1000
    );
    Mishoo

    @yevhen Thank you!

    For anyone else reading, here is how to hide the BOOKING NOTE:

    
    // hides BOOKING NOTES
    add_filter(
    	'hivepress/v1/forms/listing_update',
    	function( $form ) {
                    if(isset($form['fields']['purchase_note'])){
    					unset($form['fields']['purchase_note']);
                    }
    		return $form;
    	},
    	1000
    );
    
    Mishoo

    @yevhen, one last puzzle to solve for me is how to show the BOOKING NOTE after a booking was paid.

    Reason: this protects sensitive information shared by our hosts to their guests.

    In any case. Thank you very much! Having great user experience so far!

    yevhen developer

    Please try this PHP snippet

    add_filter(
    	'hivepress/v1/templates/booking_view_page/blocks',
    	function ($blocks, $template){
    		$order = $template->get_context('order');
    
    		if( ! $order || ! in_array($order->get_status(), ['completed', 'processing'])){
    			$blocks = hivepress()->helper->merge_trees(
    					[ 'blocks' => $blocks ],
    					[
    						'blocks' => [
    						    	'booking_note' => [
    									'type' => 'content',
    							    	'content' => '',
    						    	],
    					     	],
    				]
    				)['blocks'];
    		}
    		
    		return $blocks;
    	},
    	1000,
    	2
    );
    Mishoo

    Thank you so much! Test on my side was successful! Implemented!

    Very grateful! Dziękuję Ci! 🙂

Viewing 8 posts - 1 through 8 (of 8 total)

New Reply

This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.