Appointments+ and Marketpress new integration questions

I noticed that with the new version of Marketpress came a new version of the Appts+ Marketpress integration.

With that, I noticed that the Appointments product in the Marketpress store now has variations. All these variations seem to correlate to the different services in Appointments+. However, there's no way to tel what is what....it just shows an image, quantity, price, and SKU...the More option doesn't even show what these variations are. I also noticed that the number of variations is much larger than the actual number of services offered.

I'd like to customize these variations to add appropriate images, but again, it's hard to tell what's what.

Additionally, when an appointment is added to the shopping cart it shows up as: "Schedule an Appointment (%appointment_date%)". Is there anyway to show the name of the service with the appointment date instead of "Schedule an Appointment"?

  • NWTD

    @Michael Bissett Any word on this? I've extended support a few times since.

    One thing I've noticed is that everytime an appointment is booked, it adds that appointment service as a variation. What's the reasoning behind this?

    Also, the option to change how the appointment appears in the cart works great on the site, however, PayPal and confirmation emails still show it as "Schedule an Appointment: <appointment ID>". Is there a way to change how both of these are displayed, to show the Service and Time/Date of the appointment instead?

    Thanks!

    PS -- Support has been extended again.

  • Michael Bissett

    Hey @NWTD, really sorry for the delay on this here!

    One thing I've noticed is that everytime an appointment is booked, it adds that appointment service as a variation. What's the reasoning behind this?

    It shouldn't be adding variations like that in the first place, I'm awful curious as to how it's doing this over on your site right now. :disappointed:

    However, that would explain how you've been getting variations to show up for this in the first place, as I'm not presently seeing this occur over on my own test site.

    As my colleague Jude is away presently, I'll need to take a deeper look at things, and also set up a test subsite on my Multisite, with a domain mapped to it (in case the domain mapping's factoring into this somehow).

    In the meantime though, could you please send in the following for your Multisite via our secure contact form, so that I can compare the sites (my site, and yours) more closely:

    - Mark to my attention, the subject line should contain only: ATTN: Michael Bissett
    - Do not include anything else in the subject line, doing so may delay our response due to how email filtering works.
    - Link back to this thread
    - Include WordPress network admin access details (login address, username & password)
    - Include FTP log-in details (hostname, username & password)
    - Include any relevant URLs for your site

    IMPORTANT: Please make sure you select "I have a different question" for your topic, so it doesn't go back to forums - this and the subject line ensure that it gets assigned to me.

    https://premium.wpmudev.org/contact/

    Thanks a bunch! :slight_smile:

    Kind Regards,
    Michael

  • Michael Bissett

    Hey @NWTD, thanks for sending that in!

    I do see that it keeps adding variations on each order I process, but I'm still digging into the why of it all. Suffice it to say though, this isn't default behavior.

    My test domain's still being prepped for my test site, but I did notice that a test site I created on your hosting doesn't seem to run into the same behavior presently.

    While there is the consideration that this is also a Multisite set up with Multi-DB, I'm still wondering about the domain mapped aspect of it all (though I'm not seeing the original, unmapped domain available for selection on the subsite you mentioned?).

    I'll need to keep on digging here, but this may be something that'll require our second level support staff to come in, as we may have an odd case on our hands here (the fact that the domain mapping plugin you're using doesn't have the original, unmapped domain available for choosing for that site does concern me).

    Kind Regards,
    Michael

  • NWTD

    Thanks for looking into this.

    As far as the mapped domains are concerned, I actually changed the site's name in the network dashboard, from the subsite name to full domain. It was to help white-label some of the sites for our clients.

    FWIW, I also noticed, that I can't really delete these variations, but I can alter them for when they show up in the cart. For instance, I can give them an image, and enter a sale price/duration. It's a really nice, unintended feature.

  • Michael Bissett

    Hey @NWTD, it's me again! :slight_smile:

    After looking into this further, I'm still finding myself unable to replicate this over on my test subsite (I even tried changing the domain as you mentioned here, though it's not something I'd recommend doing, as I have found doing so to break some things in the past).

    It looks like I'll need to call in our second level support staff here, as this looks to require deeper troubleshooting to root out the cause of this odd behavior.

    Sure do appreciate your patience in the midst of all this, hope you're doing well today! :slight_smile:

    Kind Regards,
    Michael

  • Hoang Ngo

    @NWTD,

    I hope you are well today.

    Actually the create new variant each time an appointment created is the default behavior. But this is not for human to read, this is something just for the Appointments & MarketPress to store and process order data.

    Usually, this should be hide, for now, please add this code to your theme functions.php or use mu-plugins

    add_action( 'admin_head', 'hide_variants_appointments' );
    function hide_variants_appointments() {
    	if ( isset( $_GET['post'] ) && $_GET['post'] == 541 ) {
    		?>
    		<style type="text/css">
    			#mp-product-price-inventory-variants-metabox {
    				display: none;
    			}
    		</style>
    		<?php
    	}
    }

    Additionally, when an appointment is added to the shopping cart it shows up as: "Schedule an Appointment (%appointment_date%)". Is there anyway to show the name of the service with the appointment date instead of "Schedule an Appointment"?

    For this, please add this code to your theme functions.php or use mu-plugins

    add_filter( 'app_mp_product_name_in_cart', 'app_mp_product_name_in_cart', 10, 5 );
    function app_mp_product_name_in_cart( $name, $service, $worker, $start, $app ) {
    	global $appointments;
    	$date_string  = "(" . date_i18n( $appointments->datetime_format, strtotime( $app->start ) ) . ")";
    	$product_name = str_replace( $date_string, '', $name );
    	$product_name = trim( $product_name );
    	$new_name     = $product_name . '-' . $service . ' ' . $date_string;
    
    	return $new_name;
    
    }

    If you have any additional issues, please let us know and we'll be happy to help.

    Best regards,
    Hoang

  • NWTD

    Thanks for the feedback @Hoang Ngo

    Is there any way to utilize the variations to customize the way different services are shown in the cart? Such as adding a an image for each service, or even a sale price? I feel this would be a great added feature.

    As far as changing the name in the cart, I fixed that via the Appointments+ Presentation settings, but that doesn't affect how it appears in PayPal during checkout. How can I update it so that what's seen in the cart on the site is the same that's shown during PayPayl checkout? Right now appointments show up in the cart as "%service_name% (%appointment_date_time%)", but in PayPal it shows up as "Schedule Your Appointment: %appointment_id%"

    Thanks for youhelp in all this.

  • Michael Bissett

    Hey @NWTD,

    Is there any way to utilize the variations to customize the way different services are shown in the cart? Such as adding a an image for each service, or even a sale price? I feel this would be a great added feature.

    That would be a handy feature to have available for each service, I'd advise opening a feature request for that over here:

    https://premium.wpmudev.org/forums/forum/feature-suggestions#question

    In regards to this though:

    As far as changing the name in the cart, I fixed that via the Appointments+ Presentation settings, but that doesn't affect how it appears in PayPal during checkout.

    I do see what you mean here, I'm seeing myself being able to produce similar results over on my test site (for me, I'm seeing it some up as "Appointment: 2"), I've informed the developer of this, so that this can be looked into further.

    Kind Regards,
    Michael

  • Hoang Ngo

    @NWTD,

    I hope you are well today.

    For the PayPal product info, we will need to change the plugin code a little bit.
    In the file /appointments/includes/class_app_mp_bridge.php line 117, you will see a code line like this
    'post_title' => get_the_title($post_id),
    Please change it to
    'post_title' => apply_filters('appointment_product_title',get_the_title($post_id),$post_id,$app_id,$service,$worker,$start,$end),
    Now, please add this code to your theme functions.php or use mu-plugins

    add_filter( 'appointment_product_title', 'appointment_product_title', 10, 7 );
    function appointment_product_title( $title, $post_id, $app_id, $service, $worker, $start, $end ) {
    	global $appointments;
    	$date_string = "(" . date_i18n( $appointments->datetime_format, strtotime( $app->start ) ) . ")";
    	$title       = $service . ' ' . $date_string;
    
    	return $title;
    }

    I will create a pull request for the hook, so you won't need to re-update the plugin code each time you update the plugin.

    Best regards,
    Hoang

  • Hoang Ngo

    Hi @NWTD,

    Please remove all the code I provided (which you added to mu-plugins or theme), and try this instead.

    add_filter( 'appointment_product_title', 'appointment_product_title', 10, 7 );
    function appointment_product_title( $title, $post_id, $app_id, $service, $worker, $start, $end ) {
    	global $appointments;
    
    	$date_string = "(" . date_i18n( $appointments->datetime_format, strtotime( $app->start ) ) . ")";
    	$title       = $appointments->get_service_name( $service ) . ' ' . $date_string;
    
    	return $title;
    }
    add_filter( 'mp_product/title', 'mp_product_title', 9999, 2 );
    function mp_product_title( $title, MP_Product $product ) {
    	if ( $product->is_variation() ) {
    		//some case product post will fail
    		$post = get_post($product->ID);
    		$parent = get_post( $post->post_parent );
    		if ( strpos( $parent->post_content, '[app_' ) !== false ) {
    			//this is app variant
    			return $post->post_title;
    		}
    	}
    
    	return $title;
    }

    Please note that, this code only works for new appointment, the old in the cart won't change. So for test, please clear the cart first.

    Best regards,
    Hoang

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.