Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter aotyehel

    (@aotyehel)

    I found this…

    https://github.com/ibericode/mc4wp-snippets/blob/master/integrations/woocommerce/list-choice.php

    …not sure if this is what I need – or which file (and where) to put it.

    Plugin Author Danny van Kooten

    (@dvankooten)

    Hi Aotyehel,

    What’s the HTML for the checkboxes look like? And do these checkboxes represent a “grouping” in your MailChimp account?

    Thread Starter aotyehel

    (@aotyehel)

    Hi Danny,

    I used your form generator to create the code:

    <p>
        <label>Which optional emails would you like to receive?</label>
        <label>
            <input name="GROUPINGS[13877][]" type="checkbox" value="33437" checked><span>Special Offers</span>
        </label>
        <label>
            <input name="GROUPINGS[13877][]" type="checkbox" value="33441" checked><span>Newsletter</span>
        </label>
    </p>

    …which matches the grouping in mailchimp.

    Plugin Author Danny van Kooten

    (@dvankooten)

    Hi Aothyehel,

    That’s a great start, there’s just one more thing we need to do to get this to work. We need to tell our plugin to grab the values for these fields and send it to MailChimp too.

    add_filter( 'mc4wp_integration_merge_vars', function( $vars ) {
    
       if( isset( $_POST['GROUPINGS'] ) ) {
          $vars['GROUPINGS'] = $_POST['GROUPINGS'];
       }
    
       return $vars;
    });

    Hope that helps. If not, let me know!

    Hi Danny… I just implemented this on our WooCommerce checkout page and it works great. Thanks for the tip. I actually set the group fields to “hidden” so it just automatically adds the groups on purchase. We just wanted to make sure that those who purchase get added to the appropriate interest group on purchase to customize the email they receive.

    This does make me wonder, however, why are there options on the WooCommerce integrations panel pertaining to Groups (“Update existing subscribers?” and “Replace interest groups?”) if this doesn’t actually happen without this custom code? Do those options actually do anything? Am I missing something?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WooCommerce billing to MailChimp checkbox group sync’ is closed to new replies.