Editing Email Content

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 10 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #9862

    Is there any way to alter the content of the email that is sent to confirm a booking?

    It currently displays something like this

    Dear John Smith, Thank you for booking with Grow Again.

    Your Booking Information:
    Hello World Event

    11th March 2014

    Ticket Price Ref.
    Standard £12.00 abc123
    Standard £12.00 def456
    Student £10.00 a1b2c3
    Total £34.00

    . Your booking reference is 1234

    All I want to do is change the Ticket Heading on the table to something more appropriate to my site like “Booking Type”

    I have ticket/booking types like

    Course Only
    Course + Single Room
    Course + Double Room (2People)

    I have changed all references on the front end by altering the appropriate template files but that bit of the email template is generated by an included function I think.

    Stuart Grierson
    #9883

    That’s correct – the table is produced by _eventorganiser_get_booking_table_for_email() (in includes/booking-actions.php).

    Perhaps it could be reworked to make it easier to over-ride, but currently the only way of editing that table is to use the eventorganiser_get_booking_table_for_email filter. This leaves you with two options:

    1. Use regular expressions to change the ‘tickets’ header. This can feel a bit nasty, I agree.
    2. Replace the table wholesale. Which effectively means “redoing” the table but with the changes made.

    As an example of (2)

    function my_booking_table_for_email( $booking_table, $booking_id ){
        //Either replace $booking_table or edit it using regular expression.
    
        $total_price = eo_get_booking_meta( $booking_id, 'booking_amount' );
        $total_qty = eo_get_booking_meta( $booking_id, 'ticket_quantity' );
        $tickets = eo_get_booking_tickets( $booking_id );
    
        //For example, if replacing it:...
        $booking_table = sprintf(
                '<table style="width:100%%;text-align:center;">
                    <thead style="font-weight:bold;"><tr> <th>%s</th><th> %s </th> <th>%s</th></tr></thead>
                    <tbody>',
                __( 'Booking Type', 'eventorganiserp' ),
                __( 'Price', 'eventorganiserp' ),
                __( 'Quantity', 'eventorganiserp' )
        );
    
        foreach ( $tickets as $ticket ) {
            $booking_table .= sprintf(
                    '<tr> <td>%s<td> %s </td> <td>%d</td></tr>',
                    esc_html( $ticket->ticket_name ),
                    eo_format_price( $ticket->ticket_price ),
                    $ticket->ticket_quantity
            );
        }
    
        $booking_table .= apply_filters( 'eventorganiser_get_booking_table_for_email_pre_total', '', $booking_id );
        $booking_table .= sprintf( '<tr> <td>%s</td><td> %s </td> <td>%d</td></tr></tbody></table>', __( 'Total' ), eo_format_price( $total_price ), $total_qty );
    
        return $booking_table;
    }
    add_filters( 'eventorganiser_get_booking_table_for_email', 'my_booking_table_for_email', 10, 2 );
    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 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.