Use Appointment CONFIRMED STATUS to move Woo Commerce Product Page to Checkout

I’m using Woo Commerce product pages with the following Appointments+ short code;
[app_monthly_schedule worker="3" service="328"][app_pagination month="1" step="1"][app_confirmation title="Check your details" button_text="Click Here to Complete"]

This works well, the user can book an appointment then gets returned back to the Woo Commerce product page.
The user can then exit the product page or press CHECKOUT, which is what I would prefer them to do.

A better solution which is my question here, would be to use the Appointments+ - Appointment CONFIRMED STATUS to move the product page to Checkout.

The current code in Woo Commerce Single Product is as follows:

<form class="cart" method="post" enctype='multipart/form-data'>
	 	<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>

	 	<input type="hidden" name="add-to-cart" value="<?php echo esc_attr( $product->id ); ?>" />

	 	<button type="submit" class="single_add_to_cart_button button alt"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>

		<?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
	</form>

Basically the Button is waiting for the User to press add to cart.

What I would like is possibly an IF ELSE statement but not sure how to utilize the Appointment CONFIRMED STATUS

IF Appointment CONFIRMED STATUS is true then
go to Checkout
ELSE

<form class="cart" method="post" enctype='multipart/form-data'>
	 	<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>

	 	<input type="hidden" name="add-to-cart" value="<?php echo esc_attr( $product->id ); ?>" />

	 	<button type="submit" class="single_add_to_cart_button button alt"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>

		<?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
	</form>

END IF

Any help ideas appreciated

  • Rupok
    • Support Ninja

    Hi Colin, hope you had a wonderful day.

    Our plugin developer can give you best idea regarding how to catch return status. So I'm pinging him to provide his valuable feedback here.

    Please keep in mind, our developers work round the clock and they have to deal with lots of critical issues and other things. So it may take a little while for them to check this and provide a feedback.

    Have a nice day. Cheers!
    Rupok

  • Ignacio
    • HummingBird

    Hi Colin

    This one is very tricky as you need first to know the appointment ID. Otherwise you won't be able to do it. This is a very basic example to check an appointment confirmed status:

    $appointment = appointments_get_appointment( $appointment_id );
    if ( 'confirmed' === $appointment->status ) {
    
    }
    else {
    
    }

    But you need to know that $appointment_id value.

  • Colin
    • Site Builder, Child of Zeus

    Thank you both for your replies.

    Have had a rethink on this and believe It should work without the IF / ELSE, just needs to Automate the add to cart - go to checkout button function.
    With my setup the Appointment+ short codes are implemented from within the Woo Commerce Product page, when the Appointment is Completed (confirmed) it returns to the Woo Commerce Product page.
    The Appointment info is no longer needed as the product info is what needs to be sent to the cart / checkout.

    If the Appointment is cancelled its redirected to another page.

    So should just be a case of removing the button input, but i suspect without this button it may go straight to the cart / checkout before the Appointment is completed.

    THIS DOES NOT WORK AS THE PRODUCT PAGE DOES NOT KNOW OF ANY CONDITION CHANGE ie that the Appointment has been made.

  • Colin
    • Site Builder, Child of Zeus

    Looking at Appointments+ Shortcodes
    [app_my_appointments status="confirmed"] this does display the Logged in users list of "confirmed" appointments in the Woo Commerce product Page.
    Thinking;
    [app_my_appointments status="active,confirmed"] should display the Logged in users actual "current" appointment, but yes would list all "active,confirmed" for the logged in user.
    "Active" is not currently a short code argument for [app_my_appointments]

    I'll have a look at the code for this shortcode

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.