Hook/Filter post_get_birs_location

Posted · Add Comment

Scheduler Forums BirchPress Scheduler Hook/Filter post_get_birs_location

This topic contains 9 replies, has 3 voices, and was last updated by  Luke 9 years, 3 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #11211

    Philipp
    Participant

    Hi there,

    I want to change the function which sets the Location for an appointment and use some custom fields instead. Can you please tell me, how to change the following function in includes/model/imp.php line 289

    static function post_get_birs_location( $location ) {
          birch_assert( is_array( $location ) && isset( $location['post_type'] ) );
          if ( isset( $location['post_title'] ) ) {
              $location['_birs_location_name'] = $location['post_title'];
          }
          return $location;
      }

    I’m not able to handle the functions inside classes.

    It’s pretty urgent so it would be great to get a answer ASAP.

    Thanks,

    Philipp

    #11234

    Luke
    Keymaster

    Hi Philipp,

    The location cannot be set with a value of custom field. Could you tell me what exactly you want to achieve?

    #11241

    Philipp
    Participant

    Hi Luke,

    I’m hiding the Custom Post Type “Location” as for my usage the customers have to choose the service first and then the provider. So instead of the CPT I’m using custom fields for “service” to save the information where to find it.
    Everything is fine except the {location_name} tag, as it uses the title of the CPT “Location”. All I want to do is to modify how the {location_tag} is generated to let it use the custom fields instead.

    Best regards,

    Philipp

    #11246

    Philipp
    Participant

    Hi again,
    just because I’m wondering. is there a changelog for version 2.7.6.B? I get an update notice but I’ve no idea what changed.

    Best regards,

    Philipp

    #11248

    Luke
    Keymaster

    Hi Philip,

    You could go to the Settings -> Form Builder page and edit the ‘Appointment Info’ block to modify the label of the Location field.

    Regarding the changlog of version 2.7.6, we will post it as soon as possible.

    #11249

    Jennifer
    Keymaster

    Hi Philipp,

    Some bugs are fixed in V2.7.6. No new features are introduced.

    #11409

    Philipp
    Participant

    Hi Luke & Jennifer,

    thanks a lot for your replies. Unfortunately they don’t provide much information. I haven’t asked many questions but non of them got a useful answer. As I had to customize some functions inside the plugin files (there was no way to customize them with filters or hooks) I’m not sure whether it’s necessary for me to update to the latest version. Usually a short look to a changeling helps the users to see what files are changed and which bugs are fixed.

    What I wanted to do is: I’m completely hiding the “location” and just added one default one. Then I added custom fields to the services with the information, where to find them. In eMails and ICS-Files, I want to show those custom fields instead of {location_name}. So now I did the following to adjust the output:

    static function post_get_birs_location( $location ) {
            birch_assert( is_array( $location ) && isset( $location['post_type'] ) );
            if ( isset( $location['post_title'] ) ) {
                $location['_birs_location_name'] = $location['post_title'];
            }
    
            /*
            |------------------------------------------------------------------------------------
            | HWW EDIT START
            |------------------------------------------------------------------------------------
            */
    
            global $staff_destination;
    
            $destination_id = $_POST['birs_appointment_service'];
            if(!$destination_id){
                $destination_id = $_GET['dest_id'];
            }
            if(!$destination_id && $staff_destination){
                $destination_id = $staff_destination;
            }
    
            $hall = get_field('itb_hall', $destination_id);
            $hall_no = substr($hall, 0, strpos($hall, ' ('));
            $booth_no = get_field('itb_booth', $destination_id);
    
            $location['_birs_location_name'] = 'Hall '.$hall_no.', Booth '.$booth_no;
    
            /*
            |------------------------------------------------------------------------------------
            | HWW EDIT END
            |------------------------------------------------------------------------------------
            */
    
            return $location;
        }

    It works in most cases, but it would be great to just get the $service_idin this function. I hadn’t success to achieve this.

    Best regards,

    Philipp

    #11441

    Luke
    Keymaster

    Hi Philipp,

    Please hook to the ‘birchschedule_model_mergefields_get_appointment1on1_merge_values’ filter to change the values of merge tags. The code should be like this.


    add_filter('birchschedule_model_mergefields_get_appointment1on1_merge_values', 'your_function', 20, 2);
    function your_function($appointment1on1, $appointment1on1_id) {
    //$appointment1on1 is an array with all info of an appointment.
    //modify $appointment1on1 here.
    return $appointment1on1;
    }

    #11890

    Philipp
    Participant

    Thank’s Luke. That was very helpful. It would be great to get a list of filter and hooks. Otherwise we’re forced to spend and waste a lot of time into searching and asking for them. BirchPress is a solid base for more complex appointment solutions, but for that we urgently need the list of filters and hooks.

    Cheers,

    Philipp

    #11893

    Luke
    Keymaster

    Please check out this topic for how to find hooks.

    http://www.birchpress.com/forums/topic/capturing-appointment-info

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

The forum ‘BirchPress Scheduler’ is closed to new topics and replies.

Comments are closed.