Manually send more WooCommerce fields not working
-
I constructed the code below based on the KB article and included it in functions.php of template child theme. The code shows up in the WP Theme child functions.php editor so it is being read into the theme.
<?php /** * Generate child theme functions and definitions * * @package Generate */ /* MailChimp for WordPress Send more WooCommerce subscription fields to MailChimp list https://mc4wp.com/kb/send-more-woocommerce-fields-to-list/ Earl Adamy 02/18/2017 */ add_filter( ‘mc4wp_integration_woocommerce_data’, function( $data ) { // Grab MailChimp field values from the current request $data[‘PHONE’] = sanitize_text_field( $_POST[‘billing_phone’] ); $data[‘ADDRESS1’] = sanitize_text_field( $_POST[‘billing_address_1’] ); $data[‘ADDRESS2’] = sanitize_text_field( $_POST[‘billing_address_2’] ); $data[‘CITY’] = sanitize_text_field( $_POST[‘billing_city’] ); $data[‘STATE’] = sanitize_text_field( $_POST[‘billing_state’] ); $data[‘ZIP’] = sanitize_text_field( $_POST[‘billing_postcode’] ); $data[‘COUNTRY’] = sanitize_text_field( $_POST[‘billing_country’] ); // Return the fields so the plugin knows to send them to MailChimp return $data; });
[Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]
I set the MC4WP logging to Everything and then completed a checkout. The new subscriber was added to the MC list; however none of the extra fields were posted. The debug log shows:
[2017-02-19 11:29:16] INFO: WooCommerce Checkout > Successfully subscribed xxx
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘Manually send more WooCommerce fields not working’ is closed to new replies.