• Resolved scmsteve

    (@scmsteve)


    We just noticed (unsure when it started) that our outbound order emails have a block, beneath the section containing the billing/shipping addresses, that contains the text of the checkout opt-in field for the mailing list.

    I have tested by using a WooCommerce Email Preview plugin to view the emails for an order (like the Order Details email) and when MC4WP is active this block appears and it goes away if I deactivate MC4WP.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter scmsteve

    (@scmsteve)

    I see where WooCommerce is inserting this data based on order metadata. Test like so:

    I can see where WooCommerce, in the email logic, is doing the "additional information" block. It gets two types of fields

    use Automattic\WooCommerce\Blocks\Package;
    use Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFields;

    $checkout_fields = Package::container()->get( CheckoutFields::class );
    $cf = $checkout_fields->get_order_additional_fields_with_values( $order, 'contact', 'other', 'view' );
    $of = $checkout_fields->get_order_additional_fields_with_values( $order, 'order', 'other', 'view' );

    It is the “order” additional fields that are outputting this, and it is becuase of the “_wc_other/_mc4wp/optin” metadata on the order.

    Is this a new piece of metadata, or has WooCommerce just started including it in emails recently? Is there a way to disable it?

    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey @scmsteve,

    We are not aware of this. Could be due to any recent change. Can you please share which plugin you meant by “WooCommerce Email Preview plugin? I’ll then test it out.

    Thread Starter scmsteve

    (@scmsteve)

    You could just place an order and observe the email, the plugin I mentioned doesn’t do anything special it just lets you see the emails after the fact.

    https://wordpress.org/plugins/woo-preview-emails/

    Thread Starter scmsteve

    (@scmsteve)

    I believe the code is in the ‘additional_checkout_fields()’ from woocommerce/includes/class-wc-emails.php.

    It is hooked in the _construct() for that class:

    add_action( 'woocommerce_email_customer_details', array( $this, 'additional_checkout_fields' ), 30, 3 );

    Maybe we could deregister that in a custom bit of code? But there may well be other cases where we would want/need other additional fields output. I guess the question is how/why MC4WP is storing it in a metadata that WooCommerce thinks needs to be output, right? Or deregister that and replicate the code but filter out the MC4WP metadata? But seems that would be in danger of getting out of date as their class changes in the future.

    Plugin Contributor Harish Chouhan

    (@hchouhan)

    @scmsteve Thanks for the details. Please allow us some time to look into this. Once we learn more, we will get back to you.

    Plugin Author Danny van Kooten

    (@dvankooten)

    HI @scmsteve,

    We found out that WooCommerce has an option to hide this field in the Order Confirmation email. The woocommerce_register_additional_checkout_field() function has an argument called show_in_order_confirmation which defaults to true.

    In our next plugin update, we will explicitly set this value to false to prevent the checkbox text from showing up in the emails.

    Best,
    Danny

    Thread Starter scmsteve

    (@scmsteve)

    Hi @dvankooten – Thanks for providing the information so I could hot-patch our installed version and it does seem to work. Looking forward to the updated version, and I really do appreciate your time to resolve this. UPDATE: I see you have already pushed out the new version, thank you for being so fast to resolve this!!

    • This reply was modified 7 months, 2 weeks ago by scmsteve.
    • This reply was modified 7 months, 2 weeks ago by scmsteve.
    Plugin Contributor Lap

    (@lapzor)

    The latest update that was just released has this patch included.
    Thank you for reporting the issue to us.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘WooCommerce opt-in form data being output on order emails’ is closed to new replies.