The WP e-Commerce MailChimp plugin automatically sends customer information, and e-Commerce data to MailChimp straight at point of purchase. Depending on your precise business needs, you may want to send other information along with the subscriber information.

The plugin contains a filter scmi_custom_fields which passes you the current list of fields being sent to MailChimp, and the purchase log ID. You can attach to this filter, and modify the existing fields, or add additional fields.

The code below shows how you can grab additional information from the WP e-Commerce purchase log and send it to MailChimp along with the subscriber information. In this example, we’re going to grab the customer’s postcode and send it along into a MailChimp field called POSTCODE.

function wpec_mc_custom_fields( $custom_fields, $purchase_id ) {

    global $table_prefix, $wpdb;

    // Retrieve the information we want from the purchase log record
    $sql = "SELECT unique_name,
              FROM {$table_prefix}wpsc_submited_form_data sfd,
                   {$table_prefix}wpsc_checkout_forms cf
             WHERE sfd.form_id =
               AND sfd.log_id = %d";

    $product_info = $wpdb->get_results(

    if ( ! $product_info )
        return $custom_fields;

    // Add the information to the data sent to MailChimp
    $custom_fields['POSTCODE] = $product_info['shippingpostcode']->value;

    return $custom_fields;
add_filter('smci_custom_fields', 'wpec_mc_custom_fields', 10, 2);

This entry was posted in .
Bookmark the permalink.