Include event title and description in woocommerce new order email

Home Forums Ticket Products Event Tickets Plus Include event title and description in woocommerce new order email

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #946851
    Helen
    Participant

    Hi there

    I want to include the event title and date and time in the emails that woocommerce sends out – not only to the customer but also to me. I know where to find and modify the woocommerce emails but I don’t know what code to add to make these details show up. Could you help please? Thank you.

    Helen

    #946948
    Geoff
    Member

    Hello there, Helen! Thanks for getting in touch and welcome to the forums. I hope you’re enjoying the WooTickets plugin so far. 🙂

    Good question. You can use tribe_get_events_title() to display the event title and tribe_events_get_the_excerpt() to output the event’s preview text in the email. So, for example, you can add the title in the template using:

    <?php echo tribe_get_events_title() ?>

    I hope this helps point you in the right direction. 🙂

    Cheers,
    Geoff

    #948106
    Helen
    Participant

    Hi Geoff

    Thanks for your reply. Sorry for my delay in replying again – I was expecting an email when someone replied to the post but didn’t get one for some reason.

    I inserted the code above <?php echo tribe_get_events_title() ?> into the woocommerce new order template. It didn’t insert the name of the event, only a line that reads “Upcoming Events”.

    I really need it to show the event title and ideally date and time too. Do you have any more ideas?

    Thanks for your help.

    #948139
    Geoff
    Member

    Oh shoot, sorry about that! I mistakenly gave you the function for the page title rather than the event title.

    You can try using tribe_events_title() or possibly even just the_title() instead.

    You can display the date and time details as well using tribe_get_start_date and tribe_get_start_time().

    For your reference, all of our available functions are available in our documentation. If you’re searching for information on these and other variables, the docs are a great place to find things. 🙂

    Cheers!
    Geoff

    • This reply was modified 9 years, 1 month ago by Geoff.
    #948182
    Helen
    Participant

    Hi Geoff I’ve tried <?php echo tribe_get_events_title() ?> and also <?php echo tribe_events_title() ?> but both show up as “upcoming events” not the event title. The date and time code worked fine thank you. Any more ideas on the title? I’ve been through the lists of functions and can’t find another relevant one. Is there something up with this function?

    The other related problem I have is that the event title doesn’t show up in the order details on the website after the transaction is completed. I guess if we can get this function sorted I could add it to that template somewhere?

    Thanks again for your help.

    Helen

    #948189
    Geoff
    Member

    Did you try the_title() by itself? That should definitely output the post title. 🙂

    Geoff

    • This reply was modified 9 years, 1 month ago by Geoff.
    #948196
    Helen
    Participant

    I did try that. It seemed to result in the output “checkout” like it got the page title rather than the event title. Just to be clear I am editing the woocommerce email templates not the event calendar ticket email.

    The template code is now:

    <?php
    /**
    * Admin new order email
    *
    * @author WooThemes
    * @package WooCommerce/Templates/Emails/HTML
    * @version 2.0.0
    */

    if ( ! defined( ‘ABSPATH’ ) ) {
    exit; // Exit if accessed directly
    }

    ?>

    <?php do_action( ‘woocommerce_email_header’, $email_heading ); ?>

    <p><?php printf( __( ‘You have received an order from %s. The order is as follows:’, ‘woocommerce’ ), $order->billing_first_name . ‘ ‘ . $order->billing_last_name ); ?></p>

    <?php do_action( ‘woocommerce_email_before_order_table’, $order, true, false ); ?>

    <h2>id . ‘&action=edit’ ); ?>”><?php printf( __( ‘Order #%s’, ‘woocommerce’), $order->get_order_number() ); ?> (<?php printf( ‘<time datetime=”%s”>%s</time>’, date_i18n( ‘c’, strtotime( $order->order_date ) ), date_i18n( wc_date_format(), strtotime( $order->order_date ) ) ); ?>)</h2>

    <?php echo tribe_get_events_title() ?>

    <?php echo tribe_get_event_link() ?>

    <?php echo tribe_events_title() ?>

    <?php echo the_title() ?>

    <?php echo tribe_get_start_date() ?>

    <table cellspacing=”0″ cellpadding=”6″ style=”width: 100%; border: 1px solid #eee;” border=”1″ bordercolor=”#eee”>
    <thead>
    <tr>
    <th scope=”col” style=”text-align:left; border: 1px solid #eee;”><?php _e( ‘Product’, ‘woocommerce’ ); ?></th>
    <th scope=”col” style=”text-align:left; border: 1px solid #eee;”><?php _e( ‘Quantity’, ‘woocommerce’ ); ?></th>
    <th scope=”col” style=”text-align:left; border: 1px solid #eee;”><?php _e( ‘Price’, ‘woocommerce’ ); ?></th>
    </tr>
    </thead>
    <tbody>
    <?php echo $order->email_order_items_table( false, true ); ?>
    </tbody>
    <tfoot>
    <?php
    if ( $totals = $order->get_order_item_totals() ) {
    $i = 0;
    foreach ( $totals as $total ) {
    $i++;
    ?><tr>
    <th scope=”row” colspan=”2″ style=”text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo ‘border-top-width: 4px;’; ?>”><?php echo $total[‘label’]; ?></th>
    <td style=”text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo ‘border-top-width: 4px;’; ?>”><?php echo $total[‘value’]; ?></td>
    </tr><?php
    }
    }
    ?>
    </tfoot>
    </table>

    <?php do_action( ‘woocommerce_email_after_order_table’, $order, true, false ); ?>

    <?php do_action( ‘woocommerce_email_order_meta’, $order, true, false ); ?>

    <?php do_action( ‘woocommerce_email_customer_details’, $order, $sent_to_admin, $plain_text ); ?>

    <?php do_action( ‘woocommerce_email_footer’ ); ?>

    You can see the functions I tried in the middle. You can see a screenshot of the resulting email at http://winchcombefestival.co.uk/wp-content/uploads/2015/03/Screen-Shot-2015-03-13-at-16.54.19.png
    Any thoughts?

    Thanks again.

    #948224
    Geoff
    Member

    Hi there, Helen! Sorry, I misunderstood from the beginning and assumed we were working in a different email template–thanks for clarifying!

    Try overriding the email-order-items.php file in Woo and add the following snippet in:

    if ( tribe_events_product_is_ticket( $item_meta->product->id ) ) {
    $event = tribe_events_get_ticket_event( $item_meta->product->id );
    echo get_the_title( $event );
    }

    …after this line:

    echo apply_filters( 'woocommerce_order_item_name', $item['name'], $item );

    I tested that out and seems to do the trick. What it will do, is add the event title next to the ticket name in the admin email that Woo sends out.

    I hope this helps, cheers!
    Geoff

    • This reply was modified 9 years, 1 month ago by Geoff.
    #948828
    Helen
    Participant

    Hi Geoff
    Thanks again for your help. Your suggestion above did work so thanks for that. In the end I’ve decided to just write the event name and date into the ticket name as then it shows up everywhere. I realised that even if I sorted out the emails, the event name also didn’t show up in the order when you look in “my account” at previous orders. This was essential really so people know what they’ve booked for. I got fed up tinkering with code so went the simple route!
    I have another, separate issue to this one now as well so I’ll create a new question and will probably speak to you again shortly!

    Thanks

    #948841
    Geoff
    Member

    Thanks for following up, Helen! I’m so glad the code worked, but I’m also glad you found a simpler solution that works as well.

    I’ll go ahead and close this thread, but it sounds like we’ll see you again real soon. 🙂

    Cheers!
    Geoff

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Include event title and description in woocommerce new order email’ is closed to new replies.