Okay
  Public Ticket #2971744
Email customization
Closed

Comments

  •  3
    LastGlow started the conversation

    Dear Stachethemes-Team,


    is there any chance to customize the email a customer gets after he purchased a ticket? Like sending him additional information tailored to the event he purchased a ticket for. 


    Thanks for you support!

    Best,

    Timo

  •  793
    Zhivko replied

    Hi,

    Yes. You can use the built-in WooCommerce hooks for that.

    Checkout the WooCommerce hook "woocommerce_email_after_order_table".

    Full list with the WooCommerce hooks can be seen here: https://woocommerce.github.io/code-reference/hooks/hooks.html

    Filter example:

    add_action('woocommerce_order_details_after_order_table', function (\WC_Order $order) {
        // Get products from this order
        $items = $order->get_items();     // Loop each product and check if the product has event_id meta attached to it
        foreach ($items as $item) {
            $event_id = $item->get_meta('event_id');         if (false !== filter_var($item->get_meta('event_id'), FILTER_VALIDATE_INT)) {             // Obtain the event object from the id
                // For more info about the Event_Post object check \assets\php\o.event.php file
                $event = new \Stachethemes\Stec\Event_Post($event_id);
                            // Displays custom text in your email
                printf('Here is my custom info for event: %s', $event->get_title());         }     } }, 11); // 11 so the text will appear below the "Calendar QR Code" text. If you need it before that set this value to 9


    Stachethemes Developer

  •  3
    LastGlow replied

    Thank you!