• Resolved mmcculli

    (@mmcculli)


    I am trying to send over the billing company name to MailChimp. I cannot find any documentation to tell me what is the merge field for company name. I have tried COMPANY, CNAME and COMPANYNAME. Don’t work.

    function custom_user_merge_tags($merge_vars, $user) {

    // Get the WooCommerce customer object
    $customer = new WC_Customer($user->ID);
    // Build Address Array
    $address = array();
    $address[“addr1”] = $customer->get_billing_address_1();
    $address[“addr2”] = $customer->get_billing_address_2();
    $address[“city”] = $customer->get_billing_city();
    $address[“state”] = $customer->get_billing_state();
    $address[“zip”] = $customer->get_billing_postcode();
    $address[“country”] = $customer->get_billing_country();

    //Assign to MailChimp merge tag name
    $merge_vars[‘ADDRESS’] = $address;
    $merge_vars[‘PHONE’] = custom_format_telephone((string) $customer->get_billing_phone());
    $merge_vars[‘COMPANY’] = $customer->get_billing_company();

    // return the merge tag array to be submitted.
    return $merge_vars;
    }

    add_filter(‘mailchimp_sync_user_mergetags’, ‘custom_user_merge_tags’, 100, 2);`

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Jordan Rich

    (@builtbyjordan)

    Hey @mmcculli The Company name can be set by making sure there is a Merge field for it. If there already is a merge field you can log into the Mailchimp account and view it.

    This is found in the Audience fields and Merge tags screen in Mailchimp see:

    https://mailchimp.com/help/manage-audience-signup-form-fields/#Add_and_delete_fields_in_the_audience_settings

    There you can control what the name is such as calling it CNAME or you can simply use the merge field number that is located there by default.

    If you don’t have a Mailchimp login and are simply using the API you could gain the merge fields using the API “GET
    /lists/{list_id}/merge-fields” to find out if there is company merge field and what it is.

    Once you have gained or created the merge field then in your function it should be possible to use the vars “COMPANY’ OR ‘CNAME” or MERGE(X) (where X is the default number when a new field is created.

    Thread Starter mmcculli

    (@mmcculli)

    Thank you. I was able to find the merge field name for company.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Merge Field Company Name’ is closed to new replies.