Yes, I would love that too. Though, the plugin interface has a tab called plugin, that lists all the plugins, including WooCommerce, that this plugin is compatible with. So my guess would be to buy the paid version.
-
This reply was modified 8 years, 3 months ago by
wadhwa016.
Thanks for your answer @wadhwa016, the free version doesn’t care about existing headers and styling from WooCommerce emails. All these features are in the WooCommerce add-on
Thanks @haet, but is there any way to disable it be used with WooCommerce.
Hey @wadhwa016,
If you can identify your WooCommerce emails by some specific content, subject, sender,… you can use one of these functions:
https://etzelstorfer.com/en/disable-wp-html-mail-template-for-specific-emails/
Maybe you can share your code afterwards with other users.
I understand that your plugin won’t do checks for specific plugins out of the box. But the examples you provide will work though it’s not a very reliable approach.
I wonder why the filter haet_mail_use_template can’t provide the name of the plugin that sends the e-mail.
your short how-to lists it like so:
add_filter( 'haet_mail_use_template', 'customize_template_usage', 10, 2 );
function customize_template_usage( $use_template, $mail ){
// $mail['to'] ...
// $mail['subject'] ...
// $mail['message'] ...
// $mail['headers'] ...
// $mail['attachments'] ...
// $mail['sender_plugin'] ... detected sender plugin slug i.e. 'ninja-forms','wp-e-commerce',...
return true;
}
but unfortunately $mail['sender_plugin'] is NULL for woocommerce emails.
to be honest, using string matching here is a rather poor solution and very unreliable.
@m0n0mind I agree string matching is a bad way to identify plugins but the WordPress function wp_mail() doesn’t contain ANY information about the plugin which sends an email and the filter in this function is the only way to globally modify emails.
I also check for GET and POST parameters and find criteria for each email.
a few examples:
- When Caldera Form sends an email there’s always a POST request containing the parameter ‘_cf_frm_id’
- Contact Form 7 also has a unique POST parameter ‘_wpcf7’
- Ninja Forms and Gravity Forms also have similar parameters
- WP Support Plus has a unique prefix in every email subject
- For WooCommerce and EasyDigitalDownloads I inject a string to the message body via their integrated template functions and afterwards I look for this string when sending emails
- Give Donations has either GET or POST parameters
- …
Hey Hannes,
thanks for giving some insight on how you achieved this.
So there’s currently no better solution to workaround this issue with woocommerce.
I followed your advice and implemented the same way by adding a custom string to the message body for woocommerce using its email content filter:
add_filter( 'woocommerce_mail_content', function($content) {
// check for active plugin
// https://codex.wordpress.org/Function_Reference/is_plugin_active
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if( is_plugin_active( 'wp-html-mail/wp-html-mail.php' ) ) {
$content .= '[haet_mail_no_template]'; // custom string id
}
return $content;
});
and then checking for this custom string in filter hook haet_mail_use_template as you already provided above.
hope this helps others as well.
how about adding a native check to your plugin for the existence of some special string identifier (i.e. [haet_mail_no_template] ) that one could use in email messages to control this behaviour without hooking into filters and that gets automatically removed before sending?