• Hi,

    Is there anyway to make the registration and password reset emails use the WooCommerce template Header and Footer?

    Or perhaps another way to edit them at least?

    Thanks,

    w.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Max K

    (@kaminskym)

    Hi,

    I have just added 2 hooks before and after mail sent, that will be available after next version release:

    do_action( "lrm/mail/before_sent", $mail_key );
    $mail_sent = wp_mail( $to, $subject, $mail_body );
    do_action( "lrm/mail/after_sent", $mail_key );

    So you can use “wp_mail” filter:

    
    	/**
    	 * Filters the wp_mail() arguments.
    	 *
    	 * @since 2.2.0
    	 *
    	 * @param array $args A compacted array of wp_mail() arguments, including the "to" email,
    	 *                    subject, message, headers, and attachments values.
    	 */
    	$atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) );

    Example:

    
    add_action("lrm/mail/before_sent", function() {
      add_filter("wp_mail", function($atts) {
         if ( !function_exists("wc_locate_template") ) { return $atts; }
         ob_start();
         wc_locate_template( "woocommerce/templates/emails/email-header.php" );
         echo $atts['message'];
         wc_locate_template( "woocommerce/templates/emails/email-footer.php" );
    
         $atts['message'] = ob_get_clean();
         return $atts;
      });
    });
    
    • This reply was modified 6 years, 2 months ago by Max K.
    • This reply was modified 6 years, 2 months ago by Max K.
    Thread Starter wilburlikesmith

    (@wilburlikesmith)

    Hey Thanks for the update. I am however still a little unclear whether this is now possible or not yet.

    And if so, do i just plunk the following into my child-theme fucntions file? My WooCommerce headers and footers are already in my child-theme.

    add_action("lrm/mail/before_sent", function() {
      add_filter("wp_mail", function($atts) {
         if ( !function_exists("wc_locate_template") ) { return $atts; }
         ob_start();
         wc_locate_template( "woocommerce/templates/emails/email-header.php" );
         echo $atts['message'];
         wc_locate_template( "woocommerce/templates/emails/email-footer.php" );
    
         $atts['message'] = ob_get_clean();
         return $atts;
      });
    });
    Plugin Author Max K

    (@kaminskym)

    Hi,

    Yes, add it and test.

    https://docs.woocommerce.com/wc-apidocs/function-wc_locate_template.html
    As you can see wc_locate_template first try to load templates from a theme folder.

    Max

    Thread Starter wilburlikesmith

    (@wilburlikesmith)

    Ok, I’ll test again, but maybe I need some spoon feeding. I’m just adding this in my child-theme functions file:

    add_action("lrm/mail/before_sent", function() {
    
      add_filter("wp_mail", function($atts) {
         if ( !function_exists("wc_locate_template") ) { return $atts; }
         ob_start();
         wc_locate_template( "woocommerce/templates/emails/email-header.php" );
         echo $atts['message'];
         wc_locate_template( "woocommerce/templates/emails/email-footer.php" );
    
         $atts['message'] = ob_get_clean();
         return $atts;
      });
    });

    EDIT: Checking now, could be because my location is:

    Didn’t work… wc_locate_template( “woocommerce/emails/email-footer.php” );
    Tryin… wc_locate_template( “child-theme/woocommerce/emails/email-footer.php” );

    Thread Starter wilburlikesmith

    (@wilburlikesmith)

    For one I know my other email templates are breaking down if I have them in this folder structure:

    woocommerce/templates/emails/email-footer.php

    templates must be removed.

    woocommerce/emails/email-footer.php

    But that doesn’t make the Ajax Popup modal use my header and footer ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘èmail Customisation’ is closed to new replies.