Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter dimatall

    (@dimatall)

    I have already implemented that by searching a signature phrase. It could be useful for someone else. Here is example of “Order processing” email.
    I add a signature to email template:

    function add_pot_sendgrid_order_mark($order, $sent_to_admin = false, $plain_text = false, $email = '') {
            if (!$sent_to_admin && !$plain_text) {
                echo '<span style="display:none" data-pot-sendgrid="order-confirmation-email321"></span>';
            }
    }
    add_action( 'woocommerce_email_before_order_table', 'add_pot_sendgrid_order_mark', 10, 4);

    And then catch this email by signature

    function set_email_template($args) {
            
         // True if signature has been founded
         $isOrder = strpos($args['message'], 'order-confirmation-email321');
    
         ...
    
         return $args;
    }
    add_filter('wp_mail', 'set_email_template', 100);

    Thanks @bcworkz for conversation!

    Thread Starter dimatall

    (@dimatall)

    Probably there is the only single way distinguishing one email from another – is to parse a args[‘message’] content.

    • This reply was modified 6 years, 11 months ago by dimatall.
    Thread Starter dimatall

    (@dimatall)

    Thanks for you reply @bcworkz. Yes I can add filter to wp_mail but how do I know what exactly mail is sending. e.g. I have two emails “Order confirmation” and “Newsletter”. And I have to catch and change only “Order confirmation” template. “Newsletter” template has to be as it is. I need some property like args['type'] = ('order', 'newsletter', 'sign up') to have a difference between email templates.

    • This reply was modified 6 years, 11 months ago by dimatall.
Viewing 3 replies - 1 through 3 (of 3 total)