Service provider in 2 location

Good days, I have 2 question to you.
I want to know how can select 2 locations for a same service provider.
I have downloaded the file "appointments-es_MX.po" for translate the plugin to Spanish, but I dont know where I have to save this one. I thank you for the answer.

  • Jack Kitterhing

    Hi there @Gustavo,

    Hope you're well today and thanks for your question.

    Currently a service provider, can only have one location, a workaround would be to create a couple of dummy service providers with different locations and then have the dummy service providers appointments assigned to the main provider. :slight_smile:

    For the translation, you'll need both the .po and .mo appointments language files and place them in wp-content/languages :slight_smile:

    Thanks!

    Kind Regards
    Jack.

  • Jose

    Hey @Gustavo,

    Hope you are doing great today!

    There is a way to achieve what you want using a bit of custom code.

    As you may know, dummy providers can be associated only to a single "real" provider. If there is not real provider associated, dummy users will be automatically associated to the admin.

    The "association" is not something complex, but only an email mapping: all the notifications emails for a dummy provider are redirected to the associated provider.

    This routine is made in the get_worker_email() method into appointments.php file.

    There you will see that a very handy filter is provided: 'app_dummy_email'

    This filter will receive as parameter the resolved email address and the dummy worker object.

    You should then use this filter to map specific dummy users to specific real users, and return the corresponding email. If your providers do not vary too much, I would suggest a hardcoded map like
    dummy_ID_X -> real_provider_N_email

    Your code would look roughly like this:

    function map_dummy_emails($worker_email, $worker) {
        if( $worker->ID === X ) {
            $worker_data = get_userdata( {X_assigned_provider_ID_here} );
        } else if ( $worker->ID === N ) {
            $worker_data = get_userdata( {N_assigned_provider_ID_here} );
        }
        if ( $worker_data ) {
    	$worker_email = $worker_data->user_email;
        }
        return $worker_email;
    }
    
    add_filter('app_dummy_email', 'map_dummy_emails', 20, 2);

    You can use this snippet either in your functions.php or as a "must-use" plugin.

    Of course, if you need a more dynamic assignment of users, you will need to create a more complex logic and add a setting section for that in the admin dashboard.

    Hope this helps and let me know if you have further questions.

    Cheers!
    JJ

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.