• Resolved johnegg

    (@johnegg)


    Hi Guys

    The text I enter in the email settings under ‘Email instructions’ is being added after the standard “processing order” email instructions. Is it possible to remove the standard processing message & replace it with the text in ‘Email instructions’ for my custom payment gateway?

    Also, the ‘Email instructions’ text is appearing in the manual invoice email also. We dont want it in there, only the initial processing email.

    Finally is it possible to create a custom email template so I can hard code the text into the custom payment gateway email?

    Thanks
    John

    • This topic was modified 4 years, 9 months ago by johnegg.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi @johnegg,

    First solution that comes to mind – rewrite WooCommerce email templates in your theme. Actually, standard processing email text (“Just to let you know — we’ve received your order…”) is hardcoded in the template, so I don’t see any other option for this.

    So what you need to do:

    1. Leave “Email instructions” option empty in custom gateway’s settings. This way it won’t appear in manual invoice emails and won’t interfere with our customizations below.

    2. Copy customer-processing-order.php file from \wp-content\plugins\woocommerce\templates\emails to \wp-content\themes\your_theme\woocommerce\emails. Ideally your_theme would be a child theme – this way customizations won’t disappear after theme update.

    3. Open copied customer-processing-order.php file in your theme folder (e.g. with FTP) and change line 30 from:

    
    <p><?php printf( esc_html__( 'Just to let you know &mdash; we\'ve received your order #%s, and it is now being processed:', 'woocommerce' ), esc_html( $order->get_order_number() ) ); ?></p>
    

    to something like this:

    
    <p><?php 
    	if ( 'alg_custom_gateway_1' === $order->get_payment_method() ) {
    		echo 'Your email instructions here...';
    	} else {
    		printf( esc_html__( 'Just to let you know &mdash; we\'ve received your order #%s, and it is now being processed:', 'woocommerce' ), esc_html( $order->get_order_number() ) ); 
    	}
    ?></p>
    

    here we are outputting different text (“Your email instructions here…”) for orders made with alg_custom_gateway_1 payment gateway.

    Hope you get the idea. Please let me know if you have any questions.

    Thread Starter johnegg

    (@johnegg)

    This is excellent! Thanks very much, works perfectly.

    Thread Starter johnegg

    (@johnegg)

    Hi Guys

    Thanks again, just one question how do I add line breaks in the echoed text? If I add p tags or br tags it seems to break the header logo image in the email. No image source code.

    Here is the text:

    echo “Thank you for your order. Your order is currently waiting to be approved and is due for payment in 30 days. If we need any further information our support team will get in touch with you. Once it is approved your order will be sent for shipping and you will receive an order confirmation and invoice. “;

    I need to add a line break before “Once it is approved…” so it goe son new paragraph.

    Cheers
    John

    Hi @johnegg,

    <p></p> or <br> should work fine. Be sure that you are not putting those inside esc_html() function though, as in this case it will just output it as raw text. If that doesn’t help, could you please post here the full PHP block of what you are changing?

    Thread Starter johnegg

    (@johnegg)

    Cool I think I got it working now. I was using <br /> instead of <br>

    @johnegg,

    Actually it should work with both of them – https://stackoverflow.com/questions/1946426/html-5-is-it-br-br-or-br

    Anyway, glad it’s working now. Please let me know if you need anything else. And if you like the plugin, please consider leaving me a rating.

    Thread Starter johnegg

    (@johnegg)

    Yeah it should, but must be some xhtml issue with using <br /> or something in WooCommerce. Its working, thats all I know! ?? Will leave a review sure.

    @johnegg,

    Thank you for the review, I really appreciate it!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Custom email template’ is closed to new replies.