How to make HAS RESOURCE & HAS PERSON pre-checked when creating booking product?

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WC Bookings How to make HAS RESOURCE & HAS PERSON pre-checked when creating booking product?

Tagged: 

This topic contains 6 replies, has 2 voices, and was last updated by WCFM Forum WCFM Forum 1 year, 5 months ago.

  • Author
    Posts
  • #34914
    Avatar
    Lwifunyo Mangula
    Participant

    hi,
    im asking how to make HAS RESOURCE and HAS PERSONS pre-checked by default when a vendor creating booking product?

  • #34915
    Avatar
    Lwifunyo Mangula
    Participant

    the tick to be checked by default when publishing new product

  • #34919
    WCFM Forum
    WCFM Forum
    Keymaster

    Hi,

    Please add this code to your site for the purpose –

    function wcfm_2510_product_manage_fields_general( $general_fields, $product_id, $product_type ) {
    	global $WCFM;
    	
    	if( !$product_id ) {
    		if( isset( $general_fields['_wc_booking_has_resources'] ) ) {
    			$general_fields['_wc_booking_has_resources']['dfvalue'] = 'yes';
    		}
    		
    		if( isset( $general_fields['_wc_booking_has_persons'] ) ) {
    			$general_fields['_wc_booking_has_persons']['dfvalue'] = 'yes';
    		}
    	}
    	
    	return $general_fields;
    }
    add_filter( 'wcfm_product_manage_fields_general', 'wcfm_2510_product_manage_fields_general', 100, 3 );

    Thank You

  • #34924
    Avatar
    Lwifunyo Mangula
    Participant

    thanks. it worked as i requested.

  • #34932
    WCFM Forum
    WCFM Forum
    Keymaster

    Fantastic … you are welcome 🙂

  • #34935
    Avatar
    Lwifunyo Mangula
    Participant

    and I want to add in my BOOKING OPTION in product publishing form
    – booking duration==>customer defined
    – time unity==>days
    – minimum duration==>1 day
    – maximum duration==>30 days
    – enable calendar range picker==>yes
    – Calendar display mode==>always visible

    i try to add something like this as your privious code, but unfortunately it doesnot work. Where im failing? how can i do it.

    function wcfm_2510_product_manage_fields_general( $general_fields, $product_id, $product_type ) {
    global $WCFM;

    if( !$product_id ) {
    if( isset( $general_fields[‘_wc_booking_duration_type’] ) ) {
    $general_fields[‘_wc_booking_duration_type’][‘dfvalue’] = ‘customer’;
    }

    if( isset( $general_fields[‘_wc_booking_duration’] ) ) {
    $general_fields[‘_wc_booking_has_persons’][‘dfvalue’] = ‘2’;
    }

    if( isset( $general_fields[‘_wc_booking_min_duration’] ) ) {
    $general_fields[‘_wc_booking_has_resources’][‘dfvalue’] = ‘1’;
    }

    if( isset( $general_fields[‘_wc_booking_max_duration’] ) ) {
    $general_fields[‘_wc_booking_has_persons’][‘dfvalue’] = ’30’;
    }

    if( isset( $general_fields[‘_wc_booking_enable_range_picker’] ) ) {
    $general_fields[‘_wc_booking_has_resources’][‘dfvalue’] = ‘yes’;
    }

    }

    return $general_fields;
    }
    add_filter( ‘wcfm_product_manage_fields_general’, ‘wcfm_2510_product_manage_fields_general’, 100, 3 );

  • #34936
    WCFM Forum
    WCFM Forum
    Keymaster

    Hi,

    Please don’t add such code.

    Checkbox and text fields are work differently.

    You have send me request on another topic, let’s discuss this there.

    Thank You

The topic ‘How to make HAS RESOURCE & HAS PERSON pre-checked when creating booking product?’ is closed to new replies.