Bug with “Subscribe everyone”
-
Hi, I just started using your plugin with EO. However, I noticed a bug that is a pretty big deal.
I have “Subscribe everyone” not checked and “Checked by default” checked.
However, your plugin is subscribing EVERY person who orders whether they uncheck the box at checkout or not. Please advise how I fix?
thanks
-
Hi again. I asked ChatGPT to help me debug the issue and it came back with the following. Makes sense, I hope it helps:
In
include/class-woo-emailoctopus-integration.php, the method that actually sends customers to EmailOctopus is:public function add_subscriber_callback( $order_id, $old_status, $new_status )That method runs whenever an order status changes to processing or completed. It checks a post meta flag to avoid double-subscribing, and it adds a “newsletter” tag if the checkbox was ticked—but it never bails out when the checkbox is not ticked and “Subscribe everyone” is turned off. In other words, it proceeds to subscribe every customer once the order hits processing/completed.
You can see the breadcrumbs in the code:
- Checkout stores a meta flag:
- If the checkbox is ticked, it sets
fweo_emailoctopus_subscribed = 'checked'. - If “Subscribe everyone” is on, it sets
fweo_emailoctopus_subscribed = 'all'. - If the checkbox is not ticked and “Subscribe everyone” is off, it sets nothing (empty).
- If the checkbox is ticked, it sets
- Later,
add_subscriber_callback()always tries to subscribe on status change; it only uses that meta to (a) stop re-subscribing if already'subscribed', and (b) add the “newsletter” tag if it was checked. There’s no guard like “only run if checked OR subscribe-everyone is on”.
It also gave me the following snippet as a work around:
// Block auto-subscribe for customers who did NOT opt in, without editing the plugin.
add_action('woocommerce_checkout_update_order_meta', function($order_id) {
// Read the plugin’s settings
$settings = get_option('woocommerce_fws-woo-emailoctopus_settings');
$subscribe_everyone = isset($settings['em_store_all_customers']) && $settings['em_store_all_customers'] === 'yes';
// What the plugin stored at checkout:
// - 'checked' → user ticked the box
// - 'all' → "subscribe everyone" mode
// - ''/missing → user did NOT tick the box
$flag = get_post_meta($order_id, 'fweo_emailoctopus_subscribed', true);
// If "subscribe everyone" is OFF and the user did NOT tick the box,
// set the sentinel value the plugin treats as "already handled"
if (!$subscribe_everyone && $flag !== 'checked') {
update_post_meta($order_id, 'fweo_emailoctopus_subscribed', 'subscribed');
}
}, 9999); // run AFTER the plugin sets its own meta-
This reply was modified 1 month, 3 weeks ago by
Sam.
Hi Sam,
thanks for reporting.
Strange, I remember that i’ve tested this many times. But you’re right, maybe something is changed in WooCommerce?
I will check this ASAP.Thanks. Also, I noticed that the “work around” that ChatGPT gave does work for the orders placed on the front end, but does not work for orders created via the Woo API, these are still automatically added to the contacts list. This is a problem is we use Woo to manage orders from marketplaces such as ebay and amazon (which is common).
Thanks for the additional information, in that case a test for a $_POST variable wouldn’t work too.
How do you get the newsletter checkbox value via external platforms? The integration is using a unique field name for the checkbox.
-
This reply was modified 1 month, 3 weeks ago by
Olaf Lederer.
Hi Olaf, we don’t. If we are creating orders from marketplaces you are not allowed to to send marketing emails so they just stay as unsubscribed by default. Essentially, customers should only be subscribed if they checkout via woo and your checkbox is selected.
Please check the latest plugin version where I fixed the problem.
Again, thanks for the report 😃 - Checkout stores a meta flag:
You must be logged in to reply to this topic.