Support » Plugin: Events Manager » Change the color of a reservation when it is no longer available

  • Resolved mikemkt

    (@mikemkt)


    Good evening, I would like automatically that a reservation that is no longer available in the calendar changes color (from green to red). Now I do it manually, I created an event category “booking archive” giving red color. But in the long run it is not a good thing. How could I go about making it automatic.
    https://www.ilfilarino.it/corsi-prenotazioni/

    Thanks so much
    Michele

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    Hi,

    you can try to hook into em_booking_save filter, you can then check the available event ticket or booking space and change the events category to soldout.

    e.g.

    sample em_booking_save code – https://pastebin.com/ihVugcPJ

    sample code for assigning events to events category

    
    wp_set_object_terms($EM_Booking->get_events()->post_id, event_category_id_here, EM_TAXONOMY_CATEGORY);
    

    checking events available space

    
    $EM_Booking->get_event()->get_bookings()->get_available_spaces()
    

    Thank you very much Angelo, in name and in fact. You would be so kind to tell me exactly where to enter the codes. In formatting -> event category? Or where? I didn’t understand whether to put this

    / *
    This snippet will auto approved Offline Payment Gateway
    * /
    function my_offline_auto_approve_filter ($ result, $ EM_Booking) {
    if ($ EM_Booking-> booking_meta [‘gateway’] == ‘offline’) {
    $ EM_Booking-> set_status (1, false);
    }
    return $ result;
    }
    add_filter (’em_booking_save’, ‘my_offline_auto_approve_filter’, 100, 2);

    or the other two

    wp_set_object_terms ($ EM_Booking-> get_events () -> post_id, event_category_id_here, EM_TAXONOMY_CATEGORY);

    $ EM_Booking-> get_event () -> get_bookings () -> get_available_spaces ()

    Thank you first of all for replying and I hope for your help

    Plugin Support angelo_nwl

    (@angelo_nwl)

    This might not work out of the box but should be something like this

    
    function my_offline_auto_approve_filter( $result, $EM_Booking ){
      if( $EM_Booking->get_event()->get_bookings()->get_available_spaces() <= 0 ){
        wp_set_object_terms($EM_Booking->get_events()->post_id, event_category_id_here, EM_TAXONOMY_CATEGORY);
      }
      return $result;
    }
    add_filter('em_booking_save', 'my_offline_auto_approve_filter', 100, 2);
    

    Sorry for the limited snippet, we are quite with regards to custom coding or snippet as per the support policy – http://eventsmanagerpro.com/support-policy/

    Thanks, I’ll try. But honestly I didn’t understand where to insert the code you indicated.

    Plugin Support angelo_nwl

    (@angelo_nwl)

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.