Join our new community forum for support & discussion

Join Now

Home Support Extensions Bookings Remove fields from booking in categories

Remove fields from booking in categories

  • Author
    Posts
  • Bemay1

    I used this code https://hivepress.io/support/topic/hide-bookings-extension-price-attribute-for-certain-categories-sub-categories/#post-20146 and it works, but is just missing one small field!
    The “booking days” it still appears on the field… How to also hide it?

    Bemay1

    Image showing the field

    ihor developer

    Please try hiding it with the same code, by unsettling the field with “booking_days” ID.

    Bemay1

    It did not work 🤔

    ihor developer

    Please try this snippet instead:

    add_filter(
    	'hivepress/v1/forms/listing_update',
    	function( $form ) {
    		if ( isset( $form['fields']['booking_days'] ) ) {
    			unset($form['fields'][''booking_days']);
    		}
    
    		return $form;
    	},
    	1000
    );
    Bemay1

    It works, however it is missing the part to restrict to one category! I tried to adapt the code but was not able to.
    Can you add that part, sorry to bother and thank you for helping, the support is so important!

    yevhen developer

    Please try this PHP snippet

    add_filter(
    	'hivepress/v1/forms/listing_update',
    	function( $form_args, $form ) {
    		// Categories where field should be hidden. Just change categories id here.
    		$categories_id = [1,2,3];
    
    		$listing = $form->get_model();
    		
    		if ( isset( $form_args['fields']['booking_days'] ) && array_intersect((array)$listing->get_categories__id(), $categories_id) ) {
    			unset($form_args['fields']['booking_days']);
    		}
    
    		return $form_args;
    	},
    	1000,
    	2
    );
Viewing 7 posts - 1 through 7 (of 7 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.