%tickets% table

This topic contains 9 replies, has 2 voices, and was last updated by  Stephen Harris 9 years, 1 month ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #15527

    Hi,

    the table sent to the bookee (called with %tickets%) has english <th>:

    Ticket Price Ref.
    14. – 15. April Doppelseminar 2 Tage für 1 Person €1.177,00 97bf72
    14. – 15. April Doppelseminar 2 Tage für 1 Person €1.177,00 3c8c3a
    14. – 15. April Doppelseminar 2 Tage für 2 Personen €2.177,00 6b9fa6
    14. – 15. April Doppelseminar 2 Tage für 2 Personen €2.177,00 9900ac
    Total €6.708,00

    I would need to change / translate the <th> as well as the “Total” at the end.
    Furthermore it would be nice if this table could be formatted at least a little bit.

    Any idea how I can do that?

    Thanks!

    edith mayerhofer
    #15551

    Hi Edith,

    It seems the translation domain was missing for those words, hence (assuming a translation has been provided), it wouldn’t have been translated. (Details on how to provide translations can be found here: ).

    The ticket table it self should be formatted (in a minimal fashion) – centered text, bold headings. But you can change the mark-up of the table using the filter: eventorganiser_email_ticket_list:

    add_filter( 'eventorganiser_email_ticket_list', 'my_email_tickets_table', 10, 3 );
    function my_email_tickets_table( $html, $booking_id, $booking_tickets, $booking_id){
         //$html is the mark-up for the table. Alter/replace as required.
         //$booking_tickets is a array of tickets. Each ticket in the
         //array as $ticket->ticket_price and $ticket->ticket_name etc.
         //$booking_id is the booking ID. Or it is -1 when generating the e-mail
         //for preview (see Settings > Event Organiser > Bookings)
    
          return $html;
    }
    

    Please note that e-mail client support varies from miminal to non-existent (which is why the formatting is so simple), furthermore all styling must be done in-line.

    Stephen Harris
    #15616

    Hi Stephen,

    sorry… I did not quite understand:

    “It seems the translation domain was missing for those words, hence (assuming a translation has been provided), it wouldn’t have been translated. (Details on how to provide translations can be found here: ).”

    There is no link in your post. I have worked on the .po file though… but it seems that translation domain is missing because these words aren´t in the .po file or are translated already.

    So how can I make them show in German?

    Thanks.

    • This reply was modified 9 years, 1 month ago by  edith mayerhofer.
    • This reply was modified 9 years, 1 month ago by  edith mayerhofer.
    edith mayerhofer
    #15639

    Oops, my apologies. The link is: docs.wp-event-organiser.com/i18n/.

    Although the text domain is missing the text should still appear in the .pot file. However, even with a translation provided in the appropriate .po/.mo files the text will not appear translated because the domain was missing. This will be fixed in the upcoming release (1.10.0)

    I’ve checked the patch for v1.10.0 (currently in beta) and the text appears translated (e.g. “Preis” for “Price”).

    (If you’d like early access to the beta version, I’d be more than happy to provide you with it).

    Stephen Harris
    #15674

    Hi Stephen, if the beta is ok for a live site it would be ok for me.
    On the other hand… wouldn´t it be easier if you tell me where to find this piece of code and
    I just change it manually until the next release is out? Thanks. Edith

    • This reply was modified 9 years, 1 month ago by  edith mayerhofer.
    • This reply was modified 9 years, 1 month ago by  edith mayerhofer.
    edith mayerhofer
    #15697

    Hi Stephen,

    I couldn’t get this work:

    add_filter( 'eventorganiser_email_ticket_list', 'my_email_tickets_table', 10, 3 );
    function my_email_tickets_table( $html, $booking_id, $booking_tickets, $booking_id){
         //$html is the mark-up for the table. Alter/replace as required.
         //$booking_tickets is a array of tickets. Each ticket in the
         //array as $ticket->ticket_price and $ticket->ticket_name etc.
         //$booking_id is the booking ID. Or it is -1 when generating the e-mail
         //for preview (see Settings > Event Organiser > Bookings)
    
          return $html;
    }
    

    I can style the table header but as soon as I get to the arrays I get errors. You sure that you have to call
    2 x $booking-id?
    function my_email_tickets_table( $html, $booking_id, $booking_tickets, $booking_id)

    May I ask you for an example? I just want to have the table in the same font (Arial) than the rest
    of the email and of course I have to put the headers in german in it. But in the meantime I have it hardcoded.
    But therefore I can wait until version 1.10 – the table formatting probably will not change in 1.10?
    Thank you.

    edith mayerhofer
    #15702

    You sure that you have to call 2 x $booking-id?

    No, that was a typo (sorry!)

    Please find an example below. This sets the colour of the table to green, just as an illustration:

    function my_email_template( $booking_table, $booking_tickets, $booking_id ){
    
        if ( -1 == $booking_id ) {
            //Preview, fake data
            $booking_tickets = array(
                (object) array( 'ticket_name' => 'Standard', 'ticket_price' => 12, 'ticket_reference' => 'abc123' ),
                (object) array( 'ticket_name' => 'Standard', 'ticket_price' => 12, 'ticket_reference' => 'def456' ),
                (object) array( 'ticket_name' => 'Student', 'ticket_price' => 10, 'ticket_reference' => 'a1b2c3' ),
            );
            $total_price = 34;
    
        }else {
            $booking_tickets = eo_get_booking_tickets( $booking_id, false );
            $total_price = eo_get_booking_meta( $booking_id, 'booking_amount' );
        }
    
        $booking_table = sprintf(
            '<table style="width:100%%;text-align:center;color:green;">
            <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 ) );
    
        return $booking_table;
    }
    add_filter( 'eventorganiser_email_ticket_list', 'my_email_template', 10, 3 ); 
    
    Stephen Harris
    #15704

    thank you!!

    edith mayerhofer
    #15961

    Hi Stephen,

    sorry for bothering you again. My customer wants to have the quantity of each ticket in the table,
    too. Could you give me a hint how to call the quantity?

    Thank you!

    • This reply was modified 9 years, 1 month ago by  edith mayerhofer.
    edith mayerhofer
    #15963

    Each ticket (instance) is on its own line, so quantity is 1 😉

    If you wanted to group tickets by type you can change the second argument in

    eo_get_booking_tickets( $booking_id, false );
    

    to true and then looping through the returned tickets you can get the quantity by

     $ticket->ticket_quantity
    
    Stephen Harris
Viewing 10 posts - 1 through 10 (of 10 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.