Send more WooCommerce fields to list

Do you have a WooCommerce store and would you like to add more of your client's data to your MailChimp list? By default the MailChimp for WordPress plugin sends over only the NAME, FNAME, LNAME and EMAIL fields. If you would like to add some more, a little editing is required.

Manually send more WooCommerce fields to your list

To send more fields to MailChimp, you will have to tell the MailChimp for WordPress plugin which field values to grab and in which MailChimp field the data should be stored.

For example, let's send some text to the "COUNTRY" and "CITY" field in MailChimp. To do this, add the following to your functions.php file:

add_filter( 'mc4wp_integration_woocommerce_data', function( $data ) { 
	// Grab MailChimp field values from the current request
	$data['COUNTRY'] = sanitize_text_field( $_POST['billing_country'] ); 	
	$data['CITY'] = sanitize_text_field( $_POST['billing_city'] ); 

	// Return the fields so the plugin knows to send them to MailChimp
	return $data; 

With this code, you're adding the WooCommerce fields called billing_country and billing_city to your MailChimp fields called COUNTRY and CITY respectively.

You can send as many or as little fields as you want. Just make sure the fields you're sending over also exist in your MailChimp list!

If you're adding new fields to your MailChimp list, don't forget to renew your list afterwards.

A more advanced example for address fields

Let's say you have a field named "ADDR" in your MailChimp account which is of the "address" type. To send the WooCommerce checkout billing address to this field, you can use the following code.

add_filter( 'mc4wp_integration_woocommerce_data', function( $data ) {

   $data['ADDR'] = array(
      'addr1' => sanitize_text_field( $_POST['billing_address_1'] ),
      'city' => sanitize_text_field( $_POST['billing_city'] ),
      'country' => sanitize_text_field( $_POST['billing_country'] ),
      'zip' => sanitize_text_field( $_POST['billing_postcode'] ),
      'state' => sanitize_text_field( $_POST['billing_state'] ),

   return $data;

You can find a full list of the WooCommerce checkout fields here.

Was this article helpful? ·