MailPoet WooCommerce Add-on
[resolved] hooking to another action in woocommerce (8 posts)

  1. amitrahav
    Posted 2 years ago #

    how can i hock the checkbox to the mail filed on the checkout page?


  2. Sebastien Dumont
    Plugin Author

    Posted 2 years ago #

    I don't quiet understand your question.

    Are you asking if you can have the checkbox already ticked on the checkout page?

  3. amitrahav
    Posted 2 years ago #

    I want the checkbox will appear only in the checkout page after the mail input

  4. ryanpl
    Posted 2 years ago #

    I want achieve similar thing - move checkbox field.
    I tried to move checkbox field by changing plugin file
    // hook into checkout page (line 79-80)
    add_action('woocommerce_after_order_notes', array(&$this, 'on_checkout_page'));
    add_action('woocommerce_review_order_before_submit', array(&$this, 'on_checkout_page'));

    but then I receive
    Fatal error: Call to a member function get_value() on a non-object in /vol/www/...../wp-content/plugins/mailpoet-woocommerce-add-on/mailpoet-woocommerce-addon.php on line 199

    fragment of mailpoet....addon.php (line 183-202)

    * This displays a checkbox field on the checkout
    * page to allow the customer to subscribe to newsletters.
    function on_checkout_page($checkout){
    // Checks if subscribe on checkout is enabled.
    $enable_checkout = get_option('mailpoet_woocommerce_enable_checkout');
    $checkout_label = get_option('mailpoet_woocommerce_checkout_label');

    if($enable_checkout == 'yes'){
    echo '<div id="mailpoet_checkout_field">';
    //echo apply_filters('mailpoet_woocommerce_subscribe_checkout_title', '<h3>'.__('Subscribe to Newsletter', 'mailpoet_woocommerce').'</h3>');
    woocommerce_form_field('mailpoet_checkout_subscribe', array(
    'type' => 'checkbox',
    'class' => array('mailpoet-checkout-class form-row-wide'),
    'label' => htmlspecialchars(stripslashes($checkout_label)),
    ), $checkout->get_value('mailpoet_checkout_subscribe'));
    echo '</div>';

  5. ryanpl
    Posted 2 years ago #

    amitrahav try this:
    remove in /wp-content/plugins/mailpoet-woocommerce-add-on/mailpoet-woocommerce-addon.php
    add_action('woocommerce_after_order_notes', array(&$this, 'on_checkout_page'));
    and add:
    add_action('woocommerce_after_checkout_billing_form', array(&$this, 'on_checkout_page'));

    Now we can have checkbox after billing fields. In my case it's under e-mail and name fields which is almost what I would like to achieve. However I wonder how I can't set woocommerce_review_order_before_submit hook.

  6. Sebastien Dumont
    Plugin Author

    Posted 2 years ago #

    An update will be pushed today to get the settings page to work for WooCommerce v2.1 and up.

    I will discuss the location of the subscription checkbox with the MailPoet team.

    It may be another option that I can add that will allow you to place were you want it on the checkout page.

  7. Sebastien Dumont
    Plugin Author

    Posted 2 years ago #

    To all on this support topic, a plugin update has been released. Your problems should now be fixed.

  8. jkriester
    Posted 1 year ago #

    to set mailpoet newsletter under billing field:

    go to:


    change to:

    if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    // hook into checkout page - adds field after order notes.
    add_action( 'woocommerce_after_checkout_billing_form', 'on_checkout_page' );

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • MailPoet WooCommerce Add-on
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic