Confirmation email styles

This topic contains 5 replies, has 2 voices, and was last updated by  Alex Steer 9 years, 10 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #16817

    Hi Stephen,

    I need to overide the inline style in the confirmation email ticket grid.

    %tickets%

    The default style is text-align:center; for the table – i want text-align:left.

    I can’t do this with the email template or in the booking email editor – is there any way to change?

    Thanks

    Alex

    • This topic was modified 9 years, 10 months ago by  Alex Steer.
    Alex Steer
    #16823

    There’s a filter for this (filters the HTML mark-up for the tickets table). It’s probably easiest to replace the HTML wholesale:

    add_filter( 'eventorganiser_email_ticket_list', 'my_tickets_table', 4, 10 );
    function my_tickets_table( $tickets_table_html, $booking_tickets, $booking_id, $template ){
         //Replace $tickets_table_html with the desired HTML mark-up
         //$booking_tickets is an array containing tickets (and quantity thereof) booked
    
         //$template is the identifier for the template selected -- allows for
         //per template styling.
    }
    

    Although its best to replace the HTML wholesale – it’ll be easiest to do this to take the php code and modifiy it. The original table is created via eventorganiser_email_ticket_list() in includes/emails.php (line~683) – you can use the body of that function in the above, and then modify the styles as desired.

    Stephen Harris
    #16831

    Thanks for your reply Stephen.

    Is it possible to get a working example of this filter?

    I have located the html

        $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>',
        __( 'Ticket', 'eventorganiserp' ),
        __( 'Price', 'eventorganiserp' ),
        __( 'Ref.', 'eventorganiserp' )
    );
    
    foreach ( $booking_tickets as $ticket ) {
        $booking_table .= sprintf(
            '<tr> <td>%s<td> %s </td> <td>%s</td></tr>',
            esc_html( $ticket->ticket_name ),
            eo_format_price( $ticket->ticket_price ),
            $ticket->ticket_reference
        );
    }
    
    $booking_table .= apply_filters( 'eventorganiser_email_ticket_list_pre_total', '', $booking_id );
    $booking_table .= sprintf( '<tr> <td>%s</td><td> %s </td> <td></td></tr></tbody></table>', __( 'Total', 'eventorganiserp' ), eo_format_price( $total_price ) );
    
    Alex Steer
    #16839

    Thanks for looking at this.

    Also, is the double %% meant to be in the CSS?

    Alex Steer
    #16858

    Hi Alex,

    Please see http://wp-event-organiser.com/forums/topic/tickets-table/ for a working example.

    The reason for the double % (%% ) – is because the HTML is passed through sprintf(). % is a special character which needs to be escaped, hence whenether a literal % is required, it must be repeated.

    Stephen Harris
    #16869

    Cool, thanks for the link.

    Alex Steer
Viewing 6 posts - 1 through 6 (of 6 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.