• Resolved Nick Lewis

    (@nickylew)


    Hi,

    I am rearranging the fields within the Woocommerce checkout billing address form, moving the Email field to the top of the form as the first item.

    I would like to move the Mailchimp for Woocommerce checkbox for signing up to the newsletter to sit with the email field at the top of the form.

    Is there a hook for your plugin in order to re-position the checkbox to another location within the form?

    How can I over ride it and choose a new position / place it just after the email field?

    Any help would be great, thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author ryanhungate

    (@ryanhungate)

    @nickylew sorry for the radio silence on this – but that should be simple enough to do through Javascript. For instance if you’re using jQuery, you could do something like:

    
    var checkbox = jQuery('[for="mailchimp_woocommerce_newsletter"]').parent();
    jQuery('#your_target_row').after(checkbox);
    

    You’ll have to make sure this code executes in a document.ready function – but the concept should be easy enough to accomplish what you’re doing with javascript.

    We will look into making this a setting in a future release as well.

    Thread Starter Nick Lewis

    (@nickylew)

    No problem.

    I had actually been thinking of a similar solution using jQuery and DOM manipulation, so this should wor, yes!

    It would be great to get this kind of function into the plugin too though.

    Thanks!

    Thread Starter Nick Lewis

    (@nickylew)

    Hi @ryanhungate

    I am just re-visiting this as I am finding it difficult to grab all the items with jquery and re-position them.

    As each of the items is a separate DOM element with the hidden input field, custom text and checkbox, I am finding it difficult to grab of all that in one go and position is somewhere else.

    Taking your jquery code you supplied and changing the id in there to the #billing_email_field doesn’t seem to have any effect.

    Is there a way I can hook in and wrap all the content produced by the plugin in order to move and style it easier? Wrapping it within a div with a class would be great, just as you have wrapped it within html comments.

    Plugin Author ryanhungate

    (@ryanhungate)

    @nickylew I don’t know if you had tried this already but there is an option in the MailChimp plugin admin that allows you to specify the action hook name to when the checkbox gets rendered – it’s defaulting to woocommerce_after_checkout_billing_form but if you have an available hook to use, you can just update this to the correct action – it should be fine.

    Ryan

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Reposition checkbox within Checkout form’ is closed to new replies.