Adding Category to a Booking-Mail

This topic contains 6 replies, has 2 voices, and was last updated by  Stephen Harris 10 years, 3 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #13783

    Hello,

    I want to add the category name of a date to the mail which is sent to the admin if somebody makes a booking at this date.

    Regards
    Michael

    Mikesh
    #13784

    Hi Michael,

    Currently the e-mails to the admin are pre-set with no UI to change this. However, you can over-ride the e-mail process after a booking is complete. The disadvantage is that you are over-riding the sending of the admin and bookee e-mail, so you will need to implement this yourself.

    add_filter( 'eventorganiser_notify_confirmed_booking', 'my_confirmed_booking_email', 10, 2 );
    function my_confirmed_booking_email( $boolean, $booking_id ){
    
           //Send e-mail to bookee and admin
    
           return false; //Return FALSE to prevent default behaviour
     }

    This isn’t as bad as its sounds as you can effectively replicate the function eventorganiser_notify_confirmed_booking(). (being careful to remove the lines:

    //Allow plugins to over-ride the behaviour of this function
    if( !apply_filters( 'eventorganiser_notify_confirmed_booking', true, $booking_id ) ){
        return;
    } 

    and so avoiding creating a infinite loop!). To get the booked event’s categories:

     $event_id   = (int) eo_get_booking_meta( $booking_id, 'event_id' );
     $categories = get_the_terms( $event_id );

    $categories is then an array (indexed by term ID) of category objects. Each object in this array has the property name containing the categorie’s name. See the WordPress codex for more details.

    Having an option to alter the admin e-mail (as you can with the booking confirmation e-mail) is on the road map.

    Stephen Harris
    #13815

    Hey Stephan,

    thank you for your quick reply.
    I have to override this function: eventorganiser_notify_new_booking

    But if I implement this code in my plugin nothing changed:

    add_filter( 'eventorganiser_notify_new_booking', 'my_notify_new_booking', 99, 2 );
    function my_notify_new_booking( $boolean, $booking_id ) { MY NEW CODE }

    Do you have an idea, what I did wrong?

    Regards
    Michael

    Mikesh
    #13846

    Hi Mikesh,

    Where did you put that code snippet? And does your code return false; at the end to disable the default behaviour?

    Stephen Harris
    #13921

    I created a new plugin called my-event-organiser. But every changes I made, didn’t appear in the Booking Mail.

    Mikesh
    #13922
        <?php
    
        /*
        Plugin Name: My Event Organiser 
        Description: Adds Category Support for Event Organiser
        Version: 1.0
        License: GPL
        Author: Mikesh
        Author URI: www.XYZ.de
        */
    
         add_filter( 'eventorganiser_notify_new_booking', 'my_notify_new_booking', 99, 2 );
    
         function my_notify_new_booking( $boolean, $booking_id ) {
    
        .......
    
        return false; //Return FALSE to prevent default behaviour   
    
    }
    Mikesh
    #13932

    Hi Michael,

    I’m just about to send you an e-mail, because I think it’ll be easier if I can take a look at the plug-in you’ve written.

    Stephen Harris
Viewing 7 posts - 1 through 7 (of 7 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.