• Resolved kdryder

    (@kdryder)


    I am trying to set the billing city and interest group via the woocommerce checkout form using the mc4wp woocommerce integration. I am using the following code in the function.php file in my theme:

    add_filter( 'mc4wp_integration_woocommerce_subscriber_data', 'woocommerce_mailchimp_bb', 10, 1);
    function woocommerce_mailchimp_bb( $subscriber ) {
    	$subscriber->merge_fields[ "TOWN" ] = sanitize_text_field( $_POST['billing_city'] );
    	$subscriber->interests[ "aaa7c012dc" ] = true;
    	return $subscriber;
    }

    The TOWN merge field is working perfectly. But the subscribers interest is not being set.
    The interest id is correct (it is normally a variable but I just hard-coded it for testing purposes).
    And I have just installed the latest version of the plugin.

    Do you have any suggestions?
    Any help would be greatly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Lap

    (@lapzor)

    Hi,

    Is replace interest groups turned on in the WooCommerce integration settings?
    Did you copy the interest id from the MailChimp for WP > Mailchimp screen, after clicking refresh lists?

    Hope that helps!

    Kind regards,

    Thread Starter kdryder

    (@kdryder)

    Hi,

    Thanks for your quick reply. Your answer helps … sort of. At least I understand why the subscribers interest wasn’t being set. The option to replace interest groups is turned off in the integration settings. But I do that because I want to add to the interest groups when a subscriber submits another order rather than replace them. If I understand correctly I need to have the replace option on. So my next question: is there a way of adding interests to an existing subscriber?

    Thanks!

    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey @kdryder,

    Adding interest groups to existing subscribers is not possible in the core plugin. You will need to use our free add-on “MailChimp User Sync” and additional custom code that checks if user has ordered 2nd time.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘can’t set subscriber interest group with woocommerce checkout integration’ is closed to new replies.