• Hi!

    I have modified the default place of the e-mail field. Currently that is my first field in the checkout page. Is there any hook or filter that I can use to bind the newsletter checkbox to the email field? So that it moves with it? I would like to have it under the field.

    Thanks,

    Bruno

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author MailerLite

    (@mailerlite)

    Hi Bruno,

    Is your question about our signup forms or woocommerce plugins?

    If it is for the woocommerce plugin, I’m afraid there isn’t such functionality. However, you could render the signup checkbox yourself wherever you want in the checkout form by doing the following:

    • Set the checkbox to be hidden in the plugin settings.
    • Add a css rule to hide the original hidden checkout element so that it isn’t submitted with the form, something like this:
    #woo_ml_subscribe[type="hidden"] {
        display: none; 
    }
    • Render a new checkbox at the place you need with the following snippet:
     woocommerce_form_field( 'woo_ml_subscribe', array(
                'type'      => 'checkbox',
                'label'     => __('Signup for newsletter'),
            ),  0 );

    Best,

    John

    Thread Starter hefterbrumi

    (@hefterbrumi)

    Hi!

    That is awesome it was helpful. I use the woocommerce plugin. To put it in the billing section I used it like that:

    add_filter('woocommerce_checkout_fields', 'custom_mailerl_checkbox_position');
    function custom_mailerl_checkbox_position( $fields ) {
    $fields['billing']['billing_options'] = array(
    'id' => 'woo_ml_subscribe',
    'label' => __('Subscribe to newsletter'), // Add custom field label
    'type' => 'checkbox', // add field typ
    'class' => array('input-checkbox'),
    'priority' => 7, // Priority sorting option
    );
    return $fields;
    }

    It went in functions.php in child theme.

    I have two other questions:

    1. I noticed that the plugin subscribes the customer as soon as they check the checkbox, and it collects the e-mail address only. Is it possible to collect First and Last name fields too, if they are filled beforehand?
    2. Is it possible to subscribe the customer only after submitting the checkout form?

    Thanks,

    B

    Plugin Author MailerLite

    (@mailerlite)

    Hi Bruno,

    For your first question, I’m afraid that it is not possible to collect the name of the customer on top of the email before the checkout is completed. We are working on an update for this.

    However, and regarding your second question, if you enable the setting “Do not add subscribers on checkout”, the customers will be added as subscribers after the checkout is completed and in this case, the first/last name will also be collected since all information will be available.

    Best,

    John

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Newsletter checkbox under checkout email field’ is closed to new replies.