• 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)

Viewing 7 replies - 1 through 7 (of 7 total)
  • 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’];

    Thread Starter wallyO

    (@wallyo)

    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!

    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?

    Thread Starter wallyO

    (@wallyo)

    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;

    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.

    Thread Starter wallyO

    (@wallyo)

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

    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.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Just what I was looking for’ is closed to new replies.