{"id":965256,"date":"2015-05-26T16:19:49","date_gmt":"2015-05-26T23:19:49","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/sending-an-email-upon-specific-event-ticket-purchase\/"},"modified":"2015-05-28T15:01:08","modified_gmt":"2015-05-28T22:01:08","slug":"sending-an-email-upon-specific-event-ticket-purchase","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/sending-an-email-upon-specific-event-ticket-purchase\/","title":{"rendered":"Sending an email upon specific event ticket purchase"},"content":{"rendered":"<p>So I have extended the wc_email class:<\/p>\n<pre><code>class WC_Ticket_Reg_Form_Email extends WC_Email {\n    \/**\n     * Set email defaults\n     *\n     * @since 0.1\n     *\/\n    public function __construct() {\n        \/\/ set ID, this simply needs to be a unique name\n        $this-&gt;id = &#039;wc_ticket_reg_form&#039;;\n        \/\/ this is the title in WooCommerce Email settings\n        $this-&gt;title = &#039;Ticket Registration Form&#039;;\n        \/\/ this is the description in WooCommerce email settings\n        $this-&gt;description = &#039;When customer purchases a ticket for the golf event an email is sent to the customer  providing a link back to the site, enabling the customer to complete the form and submit the golfers information.&#039;;\n\n        \/\/ these are the default heading and subject lines that can be overridden using the settings\n\n        $this-&gt;heading = &#039;Ticket Registration Form&#039;;\n\n        $this-&gt;subject = &#039;Ticket Registration Form&#039;;\n\n        \/\/ these define the locations of the templates that this email should use, we&#039;ll just use the new order template since this email is similar\n\n        $this-&gt;template_html  = &#039;emails\/customer-ticket-registration-form.php&#039;;\n\n        $this-&gt;template_plain = &#039;emails\/plain\/customer-ticket-registration-form.php&#039;;\n\n        \/\/ Trigger on new paid orders\n\n        add_action( &#039;wootickets-send-tickets-email&#039;, array( $this, &#039;trigger&#039; ) );\n\n        \/\/add_action( &#039;woocommerce_order_status_failed_to_processing_notification&#039;,  array( $this, &#039;trigger&#039; ) );\n\n        $this-&gt;enabled = apply_filters( &#039;wootickets-tickets-email-enabled&#039;, &#039;yes&#039; );\n\n        \/\/ Call parent constructor to load any other defaults not explicity defined here\n\n        parent::__construct();\n\n        \/\/ this sets the recipient to the settings defined below in init_form_fields()\n\n        $this-&gt;recipient = $this-&gt;get_option( &#039;recipient&#039; );\n\n        \/\/ if none was entered, just use the WP admin email as a fallback\n\n        if ( ! $this-&gt;recipient )\n\n            $this-&gt;recipient = get_option( &#039;admin_email&#039; );\n\n    }\n\n    \/**\n     * Determine if the email should actually be sent and setup email merge variables\n     *\n     * @since 0.1\n     * @param int $order_id\n     *\/\n\n    public function trigger( $order_id ) {\n\n        \/\/ bail if no order ID is present\n\n        if ( ! $order_id )\n\n            return;\n\n        \/\/ setup order object\n\n        $this-&gt;object = new WC_Order( $order_id );\n\n        \/\/ replace variables in the subject\/headings\n\n        $this-&gt;find[] = &#039;{order_date}&#039;;\n\n        $this-&gt;replace[] = date_i18n( woocommerce_date_format(), strtotime( $this-&gt;object-&gt;order_date ) );\n\n        $this-&gt;find[] = &#039;{order_number}&#039;;\n\n        $this-&gt;replace[] = $this-&gt;object-&gt;get_order_number();\n\n        $this-&gt;find[]    = &#039;{sitename}&#039;;\n\n        $this-&gt;replace[] = get_option( &#039;blogname&#039; );\n\n        $this-&gt;recipient = $this-&gt;object-&gt;billing_email;\n\n        if ( ! $this-&gt;is_enabled() || ! $this-&gt;get_recipient() )\n\n            return;\n        \/\/ woohoo, send the email!\n        $this-&gt;send( $this-&gt;get_recipient(), $this-&gt;get_subject(), $this-&gt;get_content(), $this-&gt;get_headers(), $this-&gt;get_attachments() );\n\n    }\n<\/code><\/pre>\n<p>Where do I drop in an if statement to isolate this functionality on a per event basis? I keep looking at the trigger and it is only getting the order_id passed in. Can I push another attribute in say event_id and then:<\/p>\n<pre><code> if ( event_id == xxx ) {\n\n$this-&gt;send( $this-&gt;get_recipient(), $this-&gt;get_subject(), $this-&gt;get_content(), $this-&gt;get_headers(), $this-&gt;get_attachments() );\n\n}<\/code><\/pre>\n<p>End user flow here is visit event page, select ticket, checkout, paypal. Site admin completes order, user gets wc-order-conf email, gets ticket-reg-form email (which will contain link back to site allowing user to complete form data and submit to stakeholders), ticket email to customer.<\/p>\n<p>Currently I am getting all my emails sent but I need to filter on a per event basis and it would be nice to extend to a per ticket type basis &#8220;maybe.&#8221;  <\/p>\n<p>Also since I am the dev on this piece and the account holder is in Alaska and limited to pos internet could you please reply to jaime@bluetigerstudio.com<\/p>\n","protected":false},"template":"","class_list":["post-965256","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Sending an email upon specific event ticket purchase -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/sending-an-email-upon-specific-event-ticket-purchase\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Sending an email upon specific event ticket purchase -\" \/>\n<meta property=\"og:description\" content=\"So I have extended the wc_email class: class WC_Ticket_Reg_Form_Email extends WC_Email { \/** * Set email defaults * * @since 0.1 *\/ public function __construct() { \/\/ set ID, this simply needs to be a unique name $this-&gt;id = &#039;wc_ticket_reg_form&#039;; \/\/ this is the title in WooCommerce Email settings $this-&gt;title = &#039;Ticket Registration Form&#039;; \/\/ [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/sending-an-email-upon-specific-event-ticket-purchase\/\" \/>\n<meta property=\"article:modified_time\" content=\"2015-05-28T22:01:08+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/sending-an-email-upon-specific-event-ticket-purchase\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/sending-an-email-upon-specific-event-ticket-purchase\/\",\"name\":\"Sending an email upon specific event ticket purchase -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2015-05-26T23:19:49+00:00\",\"dateModified\":\"2015-05-28T22:01:08+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/sending-an-email-upon-specific-event-ticket-purchase\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/sending-an-email-upon-specific-event-ticket-purchase\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/sending-an-email-upon-specific-event-ticket-purchase\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Ticket Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Event Tickets Plus\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/event-tickets-plus\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Sending an email upon specific event ticket purchase\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Sending an email upon specific event ticket purchase -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/sending-an-email-upon-specific-event-ticket-purchase\/","og_locale":"en_US","og_type":"article","og_title":"Sending an email upon specific event ticket purchase -","og_description":"So I have extended the wc_email class: class WC_Ticket_Reg_Form_Email extends WC_Email { \/** * Set email defaults * * @since 0.1 *\/ public function __construct() { \/\/ set ID, this simply needs to be a unique name $this-&gt;id = &#039;wc_ticket_reg_form&#039;; \/\/ this is the title in WooCommerce Email settings $this-&gt;title = &#039;Ticket Registration Form&#039;; \/\/ [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/sending-an-email-upon-specific-event-ticket-purchase\/","article_modified_time":"2015-05-28T22:01:08+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/sending-an-email-upon-specific-event-ticket-purchase\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/sending-an-email-upon-specific-event-ticket-purchase\/","name":"Sending an email upon specific event ticket purchase -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2015-05-26T23:19:49+00:00","dateModified":"2015-05-28T22:01:08+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/sending-an-email-upon-specific-event-ticket-purchase\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/sending-an-email-upon-specific-event-ticket-purchase\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/sending-an-email-upon-specific-event-ticket-purchase\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Ticket Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/"},{"@type":"ListItem","position":4,"name":"Event Tickets Plus","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/event-tickets-plus\/"},{"@type":"ListItem","position":5,"name":"Sending an email upon specific event ticket purchase"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/965256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/965256\/revisions"}],"predecessor-version":[{"id":965390,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/965256\/revisions\/965390"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=965256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}