Hi there! Want
to see some
related articles?

Sending WooCommerce order information to Mailchimp

By default the plugin only sends the Mailchimp default fields of EMAIL, FNAME and LNAME. However, with a little bit of code dropped into your functions.php file you can send additional information to Mailchimp.

Below is some sample code on how to use the ss_wc_mailchimp_subscribe_merge_tags hook to modify the Mailchimp merge tags to include WooCommerce order information:


/************ MAILCHIMP INTEGRATION HOOKS *********/
add_filter( 'ss_wc_mailchimp_subscribe_merge_tags', 'woocommerce_mailchimp_extra_data', 10, 3 );

function woocommerce_mailchimp_extra_data( $merge_tags, $order_id, $email ) {

    // Lets grab the order
$order = wc_get_order( $order_id ); $billing_email = $order->get_billing_email();
$billing_phone = $order->get_billing_phone(); $billing_total = $order->get_total(); $order_number= $order->get_order_number(); $product_list = ''; $order_items = $order->get_items( 'line_item' ); $skus = array(); foreach( $order_items as $order_item ) { $product = $order_item->get_product(); $skus[] = $product->get_sku(); } $product_list = implode( ',\n', $skus ); $new_merge_tags = array( 'BUYDATE' => $order->get_date_paid(), 'AMOUNT' => $billing_total, 'PRODUCTS' => $product_list, 'SOURCE' => $order_number ); // combine the two arrays $merge_tags = array_merge( $merge_tags, $new_merge_tags ); return $merge_tags; }