{"id":1955344,"date":"2023-05-22T03:40:34","date_gmt":"2023-05-22T10:40:34","guid":{"rendered":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/?post_type=post&#038;p=1955344"},"modified":"2024-01-12T09:49:44","modified_gmt":"2024-01-12T14:49:44","slug":"customizing-the-ticket-email-2","status":"publish","type":"post","link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/customizing-the-ticket-email-2\/","title":{"rendered":"Customizing the Ticket Email"},"content":{"rendered":"\n<p class=\"has-background\" style=\"background-color:var(--global-palette8)\">\ud83d\udc4b This article covers the template available with our legacy emails. For a full list of templates available with our new emails solution starting with <strong>Event Tickets version 5.6.0<\/strong>, see <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/k\/tickets-emails-template-files\/\" target=\"_blank\" rel=\"noreferrer noopener\">this article<\/a> about Tickets Emails templates.<meta charset=\"utf-8\"><\/p>\n\n\n\n<p><a href=\"https:\/\/theeventscalendar.com\/products\/wordpress-event-tickets\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Event Tickets<\/strong><\/a> comes with a number of template files that determine how the plugin looks and behaves. We call these <strong>views<\/strong>. You can <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/k\/customizing-template-files-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">customize these views<\/a> by placing copies of them in your theme. And that is valid for the email template as well.<\/p>\n\n\n\n<p>The email template is important, in the sense that it is basically what your user will receive and use as a ticket. So, making it your own and including the information you want and in the way you want is important.<\/p>\n\n\n\n<p>Fortunately, there are several ways to customize the ticket email template. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-customize-via-a-template-override\">Customize via a Template Override<\/h2>\n\n\n\n<p>Customizing templates is something you might be familiar with if you worked on some TEC customizations already. If you haven&#8217;t, we&#8217;d recommend you to take a look <a rel=\"noreferrer noopener\" href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/k\/customizing-template-files-2\/\" target=\"_blank\">at this article<\/a> before moving forward.<\/p>\n\n\n\n<p>First off, we need to find where the <strong>email template file<\/strong> is located in the plugin files. In this case, we\u2019re customizing a template in <a href=\"https:\/\/theeventscalendar.com\/products\/wordpress-event-tickets\/\" target=\"_blank\" rel=\"noreferrer noopener\">Event Tickets<\/a>. That means we can head over here to start looking, to find the template we&#8217;re looking for: <code>\/wp-content\/plugins\/event-tickets\/src\/views\/tickets\/email.php<\/code>.<\/p>\n\n\n\n<p>You can copy that template to <code>[your-theme]\/tribe-events\/tickets\/email.php<\/code> and then make all the modifications you want.<\/p>\n\n\n\n<p>At the top of the file, you can find the variables that you&#8217;ll receive and be available to use in that context.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-customize-via-hooks\">Customize via Hooks<\/h2>\n\n\n\n<p>Customizing via <a rel=\"noreferrer noopener\" href=\"https:\/\/developer.wordpress.org\/plugins\/hooks\/\" target=\"_blank\">hooks<\/a> requires a bit more advanced skills but its flexibility allows you to customize the email template without having to work with template overrides.<\/p>\n\n\n\n<p>The Ticket Email template comes with the following hooks:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/docs.theeventscalendar.com\/reference\/hooks\/tribe_tickets_email_include_event_date\/\" target=\"_blank\"><strong>tribe_tickets_email_include_event_date<\/strong><\/a> &#8211; Filters whether or not the event date should be included in the ticket email<\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/docs.theeventscalendar.com\/reference\/hooks\/tribe_tickets_ticket_email_ticket_top\/\" target=\"_blank\"><strong>tribe_tickets_ticket_email_ticket_top<\/strong><\/a> &#8211; Action that gives an opportunity to manipulate the current ticket before output.<\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/docs.theeventscalendar.com\/reference\/hooks\/tribe_tickets_ticket_email_after_details\/\" target=\"_blank\"><strong>tribe_tickets_ticket_email_after_details<\/strong><\/a> &#8211; Action that allows inserting content after the &#8220;ticket details&#8221; section.<\/li>\n\n\n\n<li><strong>tribe_tickets_ticket_email_ticket_bottom<\/strong> &#8211; Action that allows inserting content after the ticket bottom.<\/li>\n\n\n\n<li><strong><a href=\"https:\/\/docs.theeventscalendar.com\/reference\/hooks\/tribe_tickets_ticket_email_bottom\/\" target=\"_blank\" rel=\"noreferrer noopener\">tribe_tickets_ticket_email_bottom<\/a><\/strong> &#8211; Action that allows inserting content at the bottom of the email.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-example-snippets-using-hooks\">Example Snippets Using Hooks<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-add-events-calendar-pro-additional-fields-to-ticket-emails\">Add Events Calendar Pro Additional Fields to ticket emails<\/h4>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/theeventscalendar.com\/products\/wordpress-events-calendar\/\" target=\"_blank\">Events Calendar Pro<\/a> comes with a pretty rad functionality called <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/k\/pro-additional-fields\/\" target=\"_blank\" rel=\"noreferrer noopener\">Additional Fields<\/a>, which allows you to add fields to events. It&#8217;s great because you can display more information on your Event page. But what if you want to also include that information in your ticket email?<\/p>\n\n\n\n<p>If you&#8217;re not sure how to use snippets, we have a handy <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/k\/best-practices-for-implementing-custom-code-snippets\/\" target=\"_blank\" rel=\"noreferrer noopener\">Snippets Guide<\/a> too. <\/p>\n\n\n\n<p>Well, that could be possible by using the following snippet: <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\n\/\/* Do NOT include the opening php tag\n\nadd_action( &#039;tribe_tickets_ticket_email_after_details&#039;, &#039;tickets_events_pro_additional_fields_to_ticket_email_after_details&#039;, 10, 2 );\n\n\/**\n * Include ticket additional fields for the emails.\n *\n * @param array   $ticket The ticket data.\n * @param WP_Post $event  The post object.\n * @return void Template render has no return.\n *\/\nfunction tickets_events_pro_additional_fields_to_ticket_email_after_details( $ticket, $event ) {\n\t$additional_fields = tribe_get_custom_fields( $event-&gt;ID );\n\n\tob_start();\n\t?&gt;\n\t&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;100%&quot; align=&quot;center&quot;&gt;\n\t\t&lt;tr&gt;\n\t\t\t&lt;td&gt;\n\t\t\t\t&lt;h6 style=&quot;color:#909090 !important; margin:0 0 4px 0; font-family: &#039;Helvetica Neue&#039;, Helvetica, sans-serif; text-transform:uppercase; font-size:13px; font-weight:700 !important;&quot;&gt;&lt;?php esc_html_e( &#039;Zoom Password&#039; ); ?&gt;&lt;\/h6&gt;\n\t\t\t\t&lt;?php echo $additional_fields&#x5B;&#039;Zoom Password&#039;]; ?&gt;\n\t\t\t&lt;\/td&gt;\n\t\t&lt;\/tr&gt;\n\t&lt;\/table&gt;\n\t&lt;?php\n\t$fields = ob_get_clean();\n\n\techo $fields;\n}\n<\/pre><\/div>\n\n\n<p>For the example above, the field <code>Zoom Password<\/code> is being sent to the user via email.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-add-event-tickets-additional-fields-to-ticket-emails\">Add Event Tickets Additional Fields to Ticket Emails<\/h3>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/theeventscalendar.com\/extensions\/additional-fields-for-tickets\/\" target=\"_blank\">Event Tickets Additional Fields<\/a> is a nice extension of ours which gives you the possibility to have more fields for your tickets. It is great, and <a rel=\"noreferrer noopener\" href=\"https:\/\/theeventscalendar.com\/extensions\/additional-fields-for-tickets\/\" target=\"_blank\">you should check it out<\/a> (if you haven&#8217;t). Sometimes, you would need or want to display these additional fields in the ticket email. <\/p>\n\n\n\n<p>And that can be achieved with a code like the one below:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\n\/\/* Do NOT include the opening php tag\n\nadd_action( &#039;tribe_tickets_ticket_email_after_details&#039;, &#039;tickets_additional_fields_to_ticket_email_after_details&#039;, 10, 2 );\n\n\/**\n * Include ticket additional fields for the emails.\n *\n * @param array   $ticket The ticket data.\n * @param WP_Post $event  The post object.\n * @return void Template render has no return.\n *\/\nfunction tickets_additional_fields_to_ticket_email_after_details( $ticket, $event ) {\n\tob_start();\n\t?&gt;\n\t&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;100%&quot; align=&quot;center&quot;&gt;\n\t\t&lt;tr&gt;\n\t\t\t&lt;td&gt;\n\t\t\t\t&lt;h6 style=&quot;color:#909090 !important; margin:0 0 4px 0; font-family: &#039;Helvetica Neue&#039;, Helvetica, sans-serif; text-transform:uppercase; font-size:13px; font-weight:700 !important;&quot;&gt;&lt;?php esc_html_e( &#039;Zoom Link&#039; ); ?&gt;&lt;\/h6&gt;\n\t\t\t\t&lt;a href=&quot;&lt;?php echo esc_url( tribe_ext_tickets_additional_fields_get_meta( $ticket&#x5B;&#039;product_id&#039;], &#039;zoom_link&#039; ) ); ?&gt;&quot;&gt;&lt;?php echo esc_html( tribe_ext_tickets_additional_fields_get_meta( $ticket&#x5B;&#039;product_id&#039;], &#039;zoom_link&#039; ) ); ?&gt;&lt;\/a&gt;\n\t\t\t&lt;\/td&gt;\n\t\t\t&lt;td&gt;\n\t\t\t\t&lt;h6 style=&quot;color:#909090 !important; margin:0 0 4px 0; font-family: &#039;Helvetica Neue&#039;, Helvetica, sans-serif; text-transform:uppercase; font-size:13px; font-weight:700 !important;&quot;&gt;&lt;?php esc_html_e( &#039;Zoom Password&#039; ); ?&gt;&lt;\/h6&gt;\n\t\t\t\t&lt;?php echo esc_html( tribe_ext_tickets_additional_fields_get_meta( $ticket&#x5B;&#039;product_id&#039;], &#039;zoom_password&#039; ) ); ?&gt;\n\t\t\t&lt;\/td&gt;\n\t\t&lt;\/tr&gt;\n\t&lt;\/table&gt;\n\t&lt;?php\n\t$fields = ob_get_clean();\n\n\techo $fields;\n}\n<\/pre><\/div>\n\n\n<p>For the example above, there are two fields that are being sent to the user via email: <code>zoom_link<\/code> and <code>zoom_password<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-remove-the-qr-code-from-emails\">Remove the QR code from emails<\/h3>\n\n\n\n<p>In some cases, the QR code is not needed as part of your site tickets. It can be because you don&#8217;t do on-site registration or because you just don&#8217;t want to use them. Fortunately, you can also use hooks to remove these. All you need to do is use the following snippet:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\n\/\/ Include this in your theme&#039;s functions.php file.\nif ( class_exists( &#039;Tribe__Tickets_Plus__Main&#039; ) ) {\n    remove_action( &#039;tribe_tickets_ticket_email_ticket_bottom&#039;, array( Tribe__Tickets_Plus__Main::instance()-&gt;qr(), &#039;inject_qr&#039; ) );\n}\n<\/pre><\/div>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ud83d\udc4b This article covers the template available with our legacy emails. For a full list of templates available with our new emails solution starting with Event Tickets version 5.6.0, see this article about Tickets Emails templates. Event Tickets comes with a number of template files that determine how the plugin looks and behaves. We call&#8230;<\/p>\n","protected":false},"author":34,"featured_media":1955565,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_swpsp_post_exclude":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"ep_exclude_from_search":false,"footnotes":""},"categories":[59,84],"tags":[25,28,58,64,73],"stellar-product-taxonomy":[155,156],"class_list":["post-1955344","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-customizing-resources","category-theming-overview","tag-customizations","tag-email","tag-php","tag-qr","tag-rsvp","stellar-product-taxonomy-event-tickets","stellar-product-taxonomy-event-tickets-plus"],"acf":[],"taxonomy_info":{"category":[{"value":59,"label":"PHP &amp; Functions"},{"value":84,"label":"Templating &amp; Layout"}],"post_tag":[{"value":25,"label":"Customizations"},{"value":28,"label":"Email"},{"value":58,"label":"PHP"},{"value":64,"label":"QR"},{"value":73,"label":"rsvp"}],"stellar-product-taxonomy":[{"value":155,"label":"Event Tickets"},{"value":156,"label":"Event Tickets Plus"}]},"featured_image_src_large":["https:\/\/images.theeventscalendar.com\/kb\/uploads\/2023\/02\/social-share-1024x538.png",1024,538,true],"author_info":{"display_name":"jaimem","author_link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/author\/jaimem\/"},"comment_info":0,"category_info":[{"term_id":59,"name":"PHP &amp; Functions","slug":"customizing-resources","term_group":0,"term_taxonomy_id":59,"taxonomy":"category","description":"","parent":24,"count":101,"filter":"raw","term_order":"0","cat_ID":59,"category_count":101,"category_description":"","cat_name":"PHP &amp; Functions","category_nicename":"customizing-resources","category_parent":24},{"term_id":84,"name":"Templating &amp; Layout","slug":"theming-overview","term_group":0,"term_taxonomy_id":84,"taxonomy":"category","description":"","parent":24,"count":59,"filter":"raw","term_order":"0","cat_ID":84,"category_count":59,"category_description":"","cat_name":"Templating &amp; Layout","category_nicename":"theming-overview","category_parent":24}],"tag_info":[{"term_id":25,"name":"Customizations","slug":"customizations","term_group":0,"term_taxonomy_id":25,"taxonomy":"post_tag","description":"","parent":0,"count":177,"filter":"raw","term_order":"0"},{"term_id":28,"name":"Email","slug":"email","term_group":0,"term_taxonomy_id":28,"taxonomy":"post_tag","description":"","parent":0,"count":20,"filter":"raw","term_order":"0"},{"term_id":58,"name":"PHP","slug":"php","term_group":0,"term_taxonomy_id":58,"taxonomy":"post_tag","description":"","parent":20,"count":128,"filter":"raw","term_order":"0"},{"term_id":64,"name":"QR","slug":"qr","term_group":0,"term_taxonomy_id":64,"taxonomy":"post_tag","description":"","parent":0,"count":8,"filter":"raw","term_order":"0"},{"term_id":73,"name":"rsvp","slug":"rsvp","term_group":0,"term_taxonomy_id":73,"taxonomy":"post_tag","description":"","parent":0,"count":7,"filter":"raw","term_order":"0"}],"_links":{"self":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1955344","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/users\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1955344"}],"version-history":[{"count":2,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1955344\/revisions"}],"predecessor-version":[{"id":1957850,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1955344\/revisions\/1957850"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media\/1955565"}],"wp:attachment":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=1955344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1955344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1955344"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1955344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}