Can you have specific services for certain pages using Appointments+

I have two types of customers. New and existing. These customers have two different prices for the same service. Existing customers pay $10 per hour and new customers $15 per hour. I have two different price points for the same service set up. I've blocked access using the User Access Management plugin so that only Existing Customers can access the existing customer page. I need existing customer services to be on the existing customer page and new customer services on the new customer page. Is there a way to do this? I don't see a way using short codes so I imagine some code would have to be added to the plugin. Could you offer me some tips and instructions as to how I may go about achieving the desired effect?

Thank you kindly for your help. The plugin is built very solidly and have had no functionality issues thus far.

  • Ash

    Hello @Odie

    Welcome to WPMU community!

    I hope you are well today and thanks for asking the question.

    You need to create two service for one service provider. Then you need to create two pages for these two services. You can use the following shortcode:

    [app_monthly_schedule service="SERVICE_ID"]
    [app_confirmation]

    You will find all the shortcodes in Appointments > Shortcodes section.

    Hope it helps :slight_smile: Please feel free to ask more question if you have.

    Cheers
    Ash

  • Odie

    Yes, I saw that. The problem is; I offer two services for each type of client. For Example using the short code and yes I know this argument is not allowed, that's why I'm asking the question.
    For new customers I need these service Ids[app_monthly_schedule service="1,2"]
    For Existing Customers, I need these service IDs`[app_monthly_schedule service="3,4"]'
    The problem is, in the short code description it said you can't have multiple IDs for the service argument, but that's exactly what I need. I need certain serviceS on one page but need other serviceS on another.

    service
    Enter service ID only if you want to force the table display the service with entered ID. Default: "0" (Service is selected by dropdown). Note: Multiple selections are not allowed.
    Example: [app_monthly_schedule ... service="12"]

  • Odie

    Thank you. I appreciate the help. Since it's not available currently using short codes or settings parameters, it would be a nice update feature.

    I'm still willing to modify my core files but would like to know if it's possible to add the modifications as a child plugin, similar to the way you'd handle a child theme in WP? This way when future updates happen, I don't have to go and redo the coding changes.

  • Hoang Ngo

    Hi @Odie

    I hope you are well today.

    The tactic here is simple, firstly, for the shortcode, [app_monthly_schedule service="X"], please replace X is the default service for both page. This will make the calendar display right service for first page load.

    And then, we can use the [app_services], we will apply a small filter, which will return the right services for each page, that's will limit the services for each type of customer.

    add_filter( 'app_services', 'filter_services_by_customer' );
    function filter_services_by_customer( $services ) {
    	$new_customer_services = array(
    		Service name, must be exactly same, separate by comma
    	);
    	$old_customer_services = array(
    		Service name, must be exactly same, separate by comma
    	);
    
    	if ( is_page( 'existCust' ) ) {
    		foreach ( $services as $key=>$service ) {
    			if ( !in_array( $service->name, $old_customer_services ) ) {
    				unset($services[$key]);
    			}
    		}
    	} else {
    		foreach ( $services as $key=>$service ) {
    			if ( !in_array( $service->name, $new_customer_services ) ) {
    				unset($services[$key]);
    			}
    		}
    	};
    	return $services;
    }

    Please add this code to your theme functions.php or use mu-plugins

    If you have any issues please don't hesitate to let us know so we can assist

    Best regards,
    Hoang

  • Hoang Ngo

    Hi @Odie,

    I hope you are well today and thanks for your information.

    Please add this code to your theme functions.php or use mu-plugins

    add_action( 'wp_footer', 'trigger_service_first_load' );
    function trigger_service_first_load() {
    	?>
    	<script type="text/javascript">
    		jQuery(document).ready(function ($) {
    			if ($('.app_select_services').size() > 0) {
    				$('.app_select_services').trigger('change');
    			}
    		})
    	</script>
    <?php
    }

    This will force the select refresh when page loaded.

    If you have any issues please don't hesitate to let us know so we can assist

    Best regards,
    Hoang

  • pxwm

    Hi @Ashok and @Hoang Ngo - I hope you don't mind me chiming in

    Hi @Odie

    If I've understood your requirement correctly and that you have already created 2 x Appointment pages and restricted access using the User Access Management plugin then you could create a set of Services for your existing customers with a given price and then set up an equivalent set of Services with a slightly different name for your new customers with a different price.

    You then create 2 x Service Providers and assign the existing customer Services to the 1st Service Provider and the new customer Services to the 2nd Service Provider.

    If you then add the standard shortcodes to each Appointment page this should then allow your existing customers to select the Services with a different price and the new customers select the equivalent Service with a different price.

    If you only have 1 x 'real' Service Provider' then you could use the 'real' Service Provider for your existing customers and the dummy Service Provider for your new customers

    I hope this helps
    Regards
    SteveB

  • Hoang Ngo

    Hi @Odie,

    I hope you are well today.

    Please try this, it should work. The theme is supported jQuery, don't worries, it supported by wordpress native.

    add_action( 'wp_footer', 'trigger_service_first_load' );
    function trigger_service_first_load() {
    	?>
    	<script type="text/javascript">
    		jQuery(document).ready(function ($) {
    			if ($('.app_select_services').size() > 0) {
    	jQuery('.app_service_excerpts').find('.app_service_excerpt').first().show();
    			}
    		})
    	</script>
    <?php
    }

    Hi @pxwm,

    Many thanks for your solution, but the achievement now is we need to return different price for each type of customer, so for achieve this, the easiest way is create many services and filter the service dropdown content.

    For now, we don't have any way to chose what's services available for service dropdown, so a custom filter will needed.

    If you have any issues please don't hesitate to let us know so we can assist
    Best regards,
    Hoang

  • pxwm

    Hi @Hoang Ngo

    Many thanks for the feedback.

    However I was hoping to keep the solution and process simple without adding any bespoke code and my proposal is to set up a set of duplicate Services as follows:-

    e.g. Service1, Service2, Service3 etc with the price for existing customers
    Then using the same name for each Service create a duplicate set: Services1, Services2, Services 3 etc for new customers with a different price.

    Then create 2 x Service Providers or 1 x 'real' Service Provider then 1 x dummy Service Provider.

    Then assign the Services for existing customers to the 1st Service Provider on the 1st Appointment page
    And assign the Services for the new customers to the 2nd Service Provider on the 2nd appointment page.

    This way bespoke code would not be required.

    Do you think this would work?

    Regards
    SteveB

  • Odie

    Here's something I've been playing around with but still the same result

    add_action( 'wp_footer', 'trigger_service_first_load' );
    function trigger_service_first_load() {
    	?>
    	<script type="text/javascript">
    		jQuery(document).ready(function ($) {
    			if ($('.app_select_services').size()==0)
    			{
    				jQuery('.app_service_excerpts').find('.app_service_excerpt').first().show();
    			}
    			else
    			{
    				jQuery('.app_service_excerpts').find('.app_service_excerpt').first().hide();
    			}
    		})
    	</script>
    <?php
    }
  • Hoang Ngo

    Hi @Odie,

    Hmm, I do apologize for this inconvenience, can you please send in:

    - Mark to my attention - ATTN: Hoang Ngo
    - Link back to this thread
    - Include admin/network access
    - Include FTP
    - Include any relevant URLS for your site

    On the contact form, select "I have a different question", this ensures it comes through and gets assigned to me.

    So I can quickly fix this issue :slight_smile:

    Best regards,
    Hoang

  • Odie

    I'm not sure if you fixed it or just caching but the thumbnail and excerpt are displaying properly on my appointment page. I modified the script you sent me a little to recognize the user role and display the appropriate services for their role. Now New and existing customers can use the same form to make appointments. Here's the code I found and implemented.

    /**
     * Checks if a particular user has a role.
     * Returns true if a match was found.
     *
     * @param string $role Role name.
     * @param int $user_id (Optional) The ID of a user. Defaults to the current user.
     * @return bool
     */
    function check_user_role( $role, $user_id = null ) {
    
        if ( is_numeric( $user_id ) )
    	$user = get_userdata( $user_id );
        else
            $user = wp_get_current_user();
    
        if ( empty( $user ) )
    	return false;
    
        return in_array( $role, (array) $user->roles );
    }
    
    add_filter( 'app_services', 'filter_services_by_customer' );
    function filter_services_by_customer( $services )
    {
    	$new_customer_services = array('Web Training 1hr','Web Training 2hrs','Marketing Consulting 1hr','Marketing Consulting 2hrs','Microsoft Training 1hr','Microsoft Training 2hrs');
    
    	$old_customer_services = array('Web Training 1hr (Existing Customer)','Web Training 2hrs (Existing Customer)','Marketing Consulting 1hr (Existing Customer)','Marketing Consulting 2hrs (Existing Customer)','Microsoft Training 1hr','Microsoft Training 2hrs');
    
    	$all_services = array('Web Training 1hr','Web Training 2hrs','Marketing Consulting 1hr','Marketing Consulting 2hrs','Web Training 1hr (Existing Customer)','Web Training 2hrs (Existing Customer)','Marketing Consulting 1hr (Existing Customer)','Marketing Consulting 2hrs (Existing Customer)','Microsoft Training 1hr','Microsoft Training 2hrs');
    
    	if ( check_user_role( 'administrator' ) )
    	{
    		foreach ( $services as $key=>$service )
    		{
    			if ( !in_array( $service->name, $all_services ) )
    			{
    				unset($services[$key]);
    			}
    		}
    	}
    	else
    	{
    		if ( check_user_role( 'serveprovider' ) )
    		{
    		foreach ( $services as $key=>$service )
    			{
    				if ( !in_array( $service->name, $all_services ) )
    				{
    					unset($services[$key]);
    				}
    			}
    		}
    		else
    		{
    			if ( check_user_role( 'existcustomer' ) )
    			{
    			foreach ( $services as $key=>$service )
    				{
    					if ( !in_array( $service->name, $old_customer_services ) )
    					{
    						unset($services[$key]);
    					}
    				}
    			}
    			else
    			{
    				foreach ( $services as $key=>$service )
    				{
    					if ( !in_array( $service->name, $new_customer_services ) )
    					{
    						unset($services[$key]);
    					}
    				}
    			}
    		}
    	};
    	return $services;
    }

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.