Sending an email upon specific event ticket purchase

Home Forums Ticket Products Event Tickets Plus Sending an email upon specific event ticket purchase

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #965256
    Liorah Wichser
    Participant

    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->id = 'wc_ticket_reg_form';
            // this is the title in WooCommerce Email settings
            $this->title = 'Ticket Registration Form';
            // this is the description in WooCommerce email settings
            $this->description = '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.';
    
            // these are the default heading and subject lines that can be overridden using the settings
    
            $this->heading = 'Ticket Registration Form';
    
            $this->subject = 'Ticket Registration Form';
    
            // these define the locations of the templates that this email should use, we'll just use the new order template since this email is similar
    
            $this->template_html  = 'emails/customer-ticket-registration-form.php';
    
            $this->template_plain = 'emails/plain/customer-ticket-registration-form.php';
    
            // Trigger on new paid orders
    
            add_action( 'wootickets-send-tickets-email', array( $this, 'trigger' ) );
    
            //add_action( 'woocommerce_order_status_failed_to_processing_notification',  array( $this, 'trigger' ) );
    
            $this->enabled = apply_filters( 'wootickets-tickets-email-enabled', 'yes' );
    
            // Call parent constructor to load any other defaults not explicity defined here
    
            parent::__construct();
    
            // this sets the recipient to the settings defined below in init_form_fields()
    
            $this->recipient = $this->get_option( 'recipient' );
    
            // if none was entered, just use the WP admin email as a fallback
    
            if ( ! $this->recipient )
    
                $this->recipient = get_option( 'admin_email' );
    
        }
    
        /**
         * Determine if the email should actually be sent and setup email merge variables
         *
         * @since 0.1
         * @param int $order_id
         */
    
        public function trigger( $order_id ) {
    
            // bail if no order ID is present
    
            if ( ! $order_id )
    
                return;
    
            // setup order object
    
            $this->object = new WC_Order( $order_id );
    
            // replace variables in the subject/headings
    
            $this->find[] = '{order_date}';
    
            $this->replace[] = date_i18n( woocommerce_date_format(), strtotime( $this->object->order_date ) );
    
            $this->find[] = '{order_number}';
    
            $this->replace[] = $this->object->get_order_number();
    
            $this->find[]    = '{sitename}';
    
            $this->replace[] = get_option( 'blogname' );
    
            $this->recipient = $this->object->billing_email;
    
            if ( ! $this->is_enabled() || ! $this->get_recipient() )
    
                return;
            // woohoo, send the email!
            $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
    
        }
    

    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:

     if ( event_id == xxx ) {
    
    $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
    
    }

    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.

    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 “maybe.”

    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 [email protected]

    #965399
    Nico
    Member

    Hi there,

    Sorry to inform you that helping out with a customization like this is beyond our product support scope. One thing that might help you figuring this is out is the fact that the event ID is stored in _tribe_wooticket_for_event meta field of the Product.

    We don’t reply by e-mail since the purpose of the forums is to make answers available for other users also.

    Hope you can get that working soon, please don’t hesitate to create new topics if you need help with anything else.
    Nico

    #965444
    Liorah Wichser
    Participant

    This reply is private.

    #965883
    Nico
    Member

    You are welcome. I’ll go ahead and close this topic, but please don’t hesitate to create a new one if you need help with anything else.

    Best,
    Nico

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Sending an email upon specific event ticket purchase’ is closed to new replies.