WordPress.org

Forums

Wakker Media Newsletter Checkout Checkbox
Just what I was looking for (8 posts)

  1. wallyO
    Member
    Posted 1 year ago #

    Just installed and tested and it worked faultlessly.
    At the moment it just captures the email address, but if you edit the plugin and change line 52

    $_REQUEST['ne'] = $_POST['billing_email'];

    to

    $_REQUEST['ne'] = $_POST['billing_email'];
    $_REQUEST['nn'] = $_POST['billing_first_name'];
    $_REQUEST['ns'] = $_POST['billing_last_name'];
    $_REQUEST['nl'] = array(2, 3);

    Then it also captures the billing First name and billing Last name and sets the subscription for list 2 and list 3.
    Note: In Newsletter => Subscription Form => Preferences => When/Where, both Preference 2 and 3 would have to be set to "Even on Subscription Forms".

    Thanks Wakker Media.
    (and Stefano Lissa)
    (and woothemes)

  2. Christian Hamamdjian
    Member
    Posted 4 months ago #

    Hi wallyO,

    I have added some extra fields with WooCommerce checkout manager they are checkboxes and they will determine in the Newsletter plugin whether the subscriber will get the newsletter in English or another language and in Html or Text form.

    I have also created preferences in Newsletter with the same names.

    I am not sure how to proceed to get these choices to show automatically on the subscriber's preferences.

    Is it something like this ?
    $_REQUEST['ch1'] = $_POST['newsletter_in_english'];

  3. wallyO
    Member
    Posted 4 months ago #

    Because of the way Newsletter filters email receivers by Subscriber Preferences (lists), I would try to use $_REQUEST['nl'] to add the subscriber to the newsletter list and the English language list.
    Say , for instance you had
    a newsletter list (1),
    a receive promotional material list(2),
    an English list (3) and
    a French list (4)
    I would use 4 checkboxs for the user to choose their preferences,
    then use javascript to populate a hidden field with a comma separated list,
    for instance Promo material(2) and English(3) would populate the hidden field with the value "2, 3".
    Then I would change the code in my first post to
    $_REQUEST['nl'] = array($_POST['hidden_field']);
    Then your subscriber would be added to the Promo and English lists.
    When sending your mail in the Who Will Receive It tab choose those two lists and send your English Promo.
    The tricky bit is writing your javascript!

  4. Christian Hamamdjian
    Member
    Posted 4 months ago #

    Hi wallyO,

    Thank you for your suggestion.

    I put together a jQuery solution to place the array resulting from two sets of radio buttons into a hidden field it works well the result that shows in the field is for example "2, 5" but on the Newsletter profile I only get the first prefence checked and the second number doesn't get transfered. This also happens when I type the array straight into the field.

    On the other hand if I place an array inside Wakkermedia's plugin for example $_REQUEST['nl'] = array(2, 5); it shows both preferences checked on the profile page.

    Do you have any idea why the second number would get dropped when pulled out of the hidden field?

  5. wallyO
    Member
    Posted 4 months ago #

    Ok. Looks like 2, 3 may be being sanitized.
    Another tangent may be to give the checkboxs a value each (if WooCommerce checkout manager will do that) then process the $POST values with php to build the array.

    $_REQUEST['ne'] = $_POST['billing_email'];
    $_REQUEST['nn'] = $_POST['billing_first_name'];
    $_REQUEST['ns'] = $_POST['billing_last_name'];
    $nl_lists = array();
    $allowed_values = array(1,2,3,4);
    if(isset($_POST['cb1']) && in_array( $_POST['cb1'], $allowed_values ) ){
    	$nl_lists = $_POST['cb1'];
    }
    if(isset($_POST['cb2']) && in_array( $_POST['cb2'], $allowed_values ) ){
    	$nl_lists = $_POST['cb2'];
    }
    if(isset($_POST['cb3']) && in_array( $_POST['cb3'], $allowed_values ) ){
    	$nl_lists = $_POST['cb3'];
    }
    if(isset($_POST['cb4']) && in_array( $_POST['cb4'], $allowed_values ) ){
    	$nl_lists = $_POST['cb4'];
    }
    $_REQUEST['nl'] = $nl_lists;
  6. Christian Hamamdjian
    Member
    Posted 4 months ago #

    Hi wallyO,

    Thanks again, but I am not getting any results from this approach. No info is getting transfered.

    The field array doesn't seem to be getting sanitized as I can see the result on the confirmation page, they just don't transfer correctly to the Newsletter subscriber's data.

  7. wallyO
    Member
    Posted 4 months ago #

    The Newsletter plugin code has changed.
    $_REQUEST['nl'] = array(2, 3);
    no longer works.

  8. Christian Hamamdjian
    Member
    Posted 4 months ago #

    Hi wallyO,

    If I enter $_REQUEST['nl'] = array(2, 3); on the wakkermedia plugin it works and both checkboxes are checked on the Newsletter profile page.

    Also the WooCommerce checkout on confirmation I get the hidden field's result complete.

    The problem occurs during the transfer between WooCommerce checkout and Newsletter subscription, the array arrives incomplete.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Wakker Media Newsletter Checkout Checkbox
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.