appointments+ & marketpress autoconfirm manual payments

Having a very similar issue to this one:

https://premium.wpmudev.org/forums/topic/appointments-and-marketpress-manual-payment-question#post-810077

I'm using marketpress for payment gateways, we want a manual payment option that automatically confirms (b/c the person will be paying upon arrival).

I tried the membership suggestion listed in the thread I linked to, but despite checking to allow a certain membership level to not have to put a deposit down in my appointments settings, it still throws the appointment into "pending."

Another membership related question that I was failing at figuring out. Can you automatically put anyone who registers into a certain access level? The second question is moot if the first question doesn't actually work as a solution.

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hey there, Ali!

    As far as I know, there's not currently a system or a known workaround to automatically approve manual payments.

    How about I give second level support a holler here and see if they can whip up a simple solution for you.

    On your second question - Yes! With membership, you can set a default subscription for new site subscribers. It's on the first tab of Membership's settings.

    Thanks!

  • Ali
    • Flash Drive

    I think I figured out #2 --- it appears you have to set a subscription plan vs an access level.

    That would be great if you could get a second level support person to help out. I'm not adverse to doing my own custom code, I just haven't really been able to pinpoint where I could change this on my own.

    Maybe in the "handle_mp_payment" function?

  • Jude
    • DEV MAN

    Hi Ali

    What you want can be done with a simple code snippet

    add_filter('app_post_confirmation_status', 'confirm_manual_payments',10,5);
    function confirm_manual_payments($status, $price, $service, $worker, $user_id) {
          if("pending" === $status)
                  $status = "confirmed" ; 
    
    return $status;
    }

    Just add this to your functions.php or better still a site specific plugin if you use one.

    Cheers
    Jude

  • Ali
    • Flash Drive

    That aallmmooost works. It is confirming too early --- it sends out email confirmation right after they hit the appointment page's confirm button....but it shouldn't be sending it out until they confirm in checkout w/ marketpress b/c they could still decide to remove the appointment from the cart.

    Also, thanks for the help on this! Really appreciated

  • Jude
    • DEV MAN

    He there Ali,

    I missed the MarketPress checkout process when I gave you that code. After studying the code of both plugins. I think the best way to get this working would be to add some code to the manual-payment.php file. It has a function order_confirmation which is a placeholder for specifically this purpose.

    You can copy paste this code and it should do the trick.

    /**
       * Runs before page load incase you need to run any scripts before loading the success message page
       */
    function order_confirmation($order) {
          global $appointments ;
          if ( isset( $_COOKIE["wpmudev_appointments"] ) ):
              $apps = unserialize( stripslashes( $_COOKIE["wpmudev_appointments"] ) );
              $apps = array_values(array_filter(array_map('intval', $apps)));
                  foreach ($apps as $id) {
                      $a = $appointments->get_app($id);
                      if('pending' === $a->status)
                          $appointments->change_status('confirmed',$id);
                  }
          endif;
      }

    Let me know if it serves your purposes

    Cheers
    Jude

  • Ali
    • Flash Drive

    awesome! this was REALLY helpful. I just made a slight adjustment to it to send out the appointment confirmation emails and now it works perfectly.

    function order_confirmation($order) {
          global $appointments ;
          if ( isset( $_COOKIE["wpmudev_appointments"] ) ):
              $apps = unserialize( stripslashes( $_COOKIE["wpmudev_appointments"] ) );
              $apps = array_values(array_filter(array_map('intval', $apps)));
                  foreach ($apps as $id) {
                      $a = $appointments->get_app($id);
                      if('pending' === $a->status){
                          $appointments->change_status('confirmed',$id);
                          $appointments->send_confirmation($id);
                      }
                  }
          endif;
      }
  • Kieran
    • The Crimson Coder

    Perfect this is exactly want I am wanting too. I'm going to integrate this into my site it would be useful to automatically have this option in future versions :slight_smile:

    Would I currently have to overwrite my manual-payment.php file with every appointments+ upgrade?

    • Ali
      • Flash Drive

      I'm not a support person here, but I'm pretty sure you'd have to do a diff on your manual-payment.php file every time it updates (so that you get whatever new code they added + your custom code)....with something like beyond compare or kdiff.

  • Jude
    • DEV MAN

    Hi there @Kieran

    Would I currently have to overwrite my manual-payment.php file with every appointments+ upgrade?

    This functionality is not standard behavior. Many members would prefer to manually verify payments from this gateway before processing the order/appointment. That with no mention of spammers. So as of now you'll need to do this at every update.

    I will mark this as a feature request and we'll definitely consider it if many members request it.

    Cheers
    Jude

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.