A WordPress plugin that prevents Royal Mail tracking notes from being sent to customers as email notifications in WooCommerce, with advanced email management features.
This plugin provides comprehensive email management for WooCommerce orders, specifically targeting Royal Mail tracking communications. It can block order notes containing Royal Mail tracking information and optionally suppress completed order emails when no tracking information is available.
- Royal Mail Note Blocking: Automatically blocks order notes containing Royal Mail tracking keywords
- Email Interception: Direct email blocking before sending (more reliable than note modification)
- AST Integration: Suppress completed order emails when no tracking info exists (requires Advanced Shipment Tracking plugin)
- Configurable Keywords: Admin panel to customize blocked keywords with AND logic (all keywords must be present)
- Debug Mode: Optional logging for troubleshooting
- WooCommerce Integration: Seamlessly integrates with WooCommerce email system
- Privacy Focused: Prevents accidental sharing of tracking information
- Upload the plugin files to the
/wp-content/plugins/royal-mail-note-blocker/directory, or install the plugin through the WordPress plugins screen directly. - Activate the plugin through the 'Plugins' screen in WordPress
- Use the WooCommerce->Note Blocker screen to configure the plugin
- WordPress 5.0 or higher
- WooCommerce 5.0 or higher
- PHP 7.4 or higher
The plugin comes pre-configured to block notes containing:
- "despatched via Royal Mail"
- "tracking number is"
- "royalmail.com/portal/rm/track"
After activation, you can customize the plugin settings:
- Go to WooCommerce → Note Blocker
- Edit the list of keywords to block (one per line)
- Enable debug mode if needed for troubleshooting
- NEW: Enable AST integration to suppress completed order emails without tracking
- Save your changes
When enabled, this feature works with the Advanced Shipment Tracking plugin to suppress completed order emails if no tracking information has been added to the order. This prevents customers from receiving completion emails for orders that haven't been shipped yet.
The plugin operates on two levels:
Uses the woocommerce_email_enabled filter to block emails before they're sent when Royal Mail tracking content is detected in order notes.
When enabled, uses the woocommerce_email_enabled_customer_completed_order filter to suppress completed order emails when no tracking items exist.
3. Optionally logs the action (if debug mode is enabled)
The core functionality is based on email interception:
add_filter('woocommerce_email_enabled', array($this, 'maybe_block_email'), 10, 3);
public function maybe_block_email($enabled, $email_id, $order) {
if (!$enabled || !$order) {
return $enabled;
}
// Get all notes for this order
$notes = wc_get_order_notes(array('order_id' => $order->get_id()));
$keywords = get_option('rmnb_keywords', array());
foreach ($notes as $note) {
$all_keywords_found = true;
foreach ($keywords as $keyword) {
if (stripos($note->content, trim($keyword)) === false) {
$all_keywords_found = false;
break;
}
}
if ($all_keywords_found) {
return false; // Block the email
}
}
return $enabled;
}- Added AST (Advanced Shipment Tracking) integration
- Added option to suppress completed order emails without tracking
- Enhanced admin interface with new settings
- Improved reliability with direct email interception
- Simplified to direct email interception method
- Improved reliability and performance
- Enhanced debugging capabilities
- Changed logic to require ALL keywords (AND logic instead of OR)
- Improved keyword matching accuracy
- Added CI/CD pipeline
- Enhanced build process
- Initial release
- Basic keyword blocking functionality
- Admin settings panel
- Debug mode support
For support, please create an issue on the GitHub repository.
This plugin is licensed under the GPL v2 or later.
Contributions are welcome! Please feel free to submit a Pull Request. Wordpress plugin to intercept notes added by click&drop and set them private before the email fires