How to override appointment product manager defaults?

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WC Appointment How to override appointment product manager defaults?

This topic contains 5 replies, has 2 voices, and was last updated by Avatar me 1 day, 22 hours ago.

  • Author
    Posts
  • #93705
    Avatar
    me
    Participant

    Hi,

    I’m trying to change a few default values in /views/wc_appointments/wcfmu-view-wcappointments-products-manage.php : 55-56
    (I want to change the default value of $has_restricted_days and $restricted_days)
    I tried template override but it doesn’t seem to work for this file, even though I already overridden a few other files in the same folder by placing them in /wcfm/wc_appointments under my child theme. But this file is not being overridden like the others, for some reason.
    Another way would be to use filters to change the defaults, but there aren’t any filters provided for that.
    Can you help me with one of those two methods so I don’t have to keep modifying your base code after every update?

    Thanks.

  • #94043
    WCFM Forum
    WCFM Forum
    Keymaster

    HI,

    Well, these are possible using filter.

    Please know me what default value you want to set, I will give you code accordingly!

    Thank You

  • #94056
    Avatar
    me
    Participant

    I’d like restricted days to be enabled by default, and set to weekdays, Monday to Friday.
    This is what I put in the base code to achieve it:

    $has_restricted_days = 'yes';
    $restricted_days = array( 1, 2, 3, 4, 5 );
    

    would be awesome to use filters instead! Thanks in advance.
    PS, don’t forget to answer my question from last week. Thanks.

  • #95910
    Avatar
    me
    Participant

    Bump?

  • #96409
    WCFM Forum
    WCFM Forum
    Keymaster

    Please use this code for the purpose-

    add_filter( 'wcfm_wcappointments_availability_fields', function( $avalability_fields, $product_id ) {
    	if( !$product_id ) {
    		if( isset( $avalability_fields['_wc_appointment_has_restricted_days'] ) ) {
    			$avalability_fields['_wc_appointment_has_restricted_days']['dfvalue'] = 'yes'; 
    		}
    		if( isset( $avalability_fields['_wc_appointment_restricted_days'] ) ) {
    			$avalability_fields['_wc_appointment_restricted_days']['value'] = array(1,2,3,4,5); 
    		}
    	}
    	return $avalability_fields;
    }, 50, 2 );

    Thank You

  • #97042
    Avatar
    me
    Participant

    Thanks a lot!

You must be logged in to reply to this topic.