Title: State Field (Select)
Last modified: August 30, 2016

---

# State Field (Select)

 *  [pfurlan](https://wordpress.org/support/users/pfurlan/)
 * (@pfurlan)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/state-field-select/)
 * Hi,
 * I’m trying to add the state field (billing_state) into my MailChimp account. 
   But i’m not being successful with it.
 * What’s is the type for this field? Text, number, selection box? I had no problem
   with Name, Email and other.
 * Thank you!
 * [https://wordpress.org/plugins/woocommerce-mailchimp/](https://wordpress.org/plugins/woocommerce-mailchimp/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [logansan](https://wordpress.org/support/users/logansan/)
 * (@logansan)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/state-field-select/#post-6806998)
 * +1!!!
 *  [logansan](https://wordpress.org/support/users/logansan/)
 * (@logansan)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/state-field-select/#post-6806999)
 * Thought about using Zapier or something but there is nothing that would hook 
   this from the STATE on the checkout page, (which it should!!)
 * This is too easy to not work 🙁
 *  Plugin Author [Adam Anderly](https://wordpress.org/support/users/anderly/)
 * (@anderly)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/state-field-select/#post-6807015)
 * This should do the trick:
 *     ```
       // tie into the WooCommerce MailChimp 'ss_wc_mailchimp_subscribe_merge_vars' action filter to modify the MailChimp merge vars
       function ss_wc_modify_mailchimp_merge_fields( $merge_vars, $order_id ) {
           // By default $merge_vars will look like array( 'FNAME' => 'Joe', 'LNAME' => 'Smith', 'EMAIL' => 'joe.smith@example.com' );
   
           // Retrieve the WooCommerce order
           $order = new WC_Order( $order_id );
   
           // Get the order billing address
           $billing_address = $order->get_address( 'billing' );
   
           // Get the billing address state
           $state = $billing_address[ 'state' ];
   
           // let's add a new 'STATE' merge field - NOTE: You'll need to change this to the actual name
           // of your merge field in MailChimp
           $merge_vars[ 'STATE' ] = $state;
   
           return $merge_vars;
       }
       add_filter( 'ss_wc_mailchimp_subscribe_merge_vars' , 'ss_wc_modify_mailchimp_merge_fields', 10 , 2 );
       ```
   
 *  [logansan](https://wordpress.org/support/users/logansan/)
 * (@logansan)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/state-field-select/#post-6807018)
 * Legend. I have installed as a snippet, will test and see if it works with next
   order (hopefully order isnt broken!!) 🙂
 *  [alfaex](https://wordpress.org/support/users/alfaex/)
 * (@alfaex)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/state-field-select/#post-6807027)
 * what kind of type i use on mailchimp? Text, number, drop down?
    default form 
   of woocommerce does some juggle with the form. it use some fancy js with div,
   but the select is there, hidden.
 *     ```
       <select name="billing_state" id="billing_state" class="state_select " placeholder="" tabindex="-1" title="Estado" style="display: none;">
       <option value="wh">wherever</option>
       <option value="wn">whenever</option>
       ...
       </select>
       ```
   
 * may i ask why not work the ‘billing_state’ using ‘drop down’ ?
 *  Thread Starter [pfurlan](https://wordpress.org/support/users/pfurlan/)
 * (@pfurlan)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/state-field-select/#post-6807028)
 * what kind of type i use on mailchimp? Text, number, drop down?
    default form 
   of woocommerce does some juggle with the form. it use some fancy js with div,
   but the select is there, hidden.
 *     ```
       <select name="billing_state" id="billing_state" class="state_select " placeholder="" tabindex="-1" title="Estado" style="display: none;">
       <option value="wh">wherever</option>
       <option value="wn">whenever</option>
       ...
       </select>
       ```
   
 * may i ask why won’t work use the ‘billing_state’ with the ‘drop down’ on mailchimp
 * And it not work.
 * these is the var dump on the beginning of your snippet.
 *     ```
       array(2) {
         ["FNAME"]=>
         string(7) "TESTE x"
         ["LNAME"]=>
         string(7) "Teste y"
       }
       ```
   
 * and this is before the return
 *     ```
       array(3) {
         ["FNAME"]=>
         string(7) "TESTE x"
         ["LNAME"]=>
         string(7) "Teste y"
         ["billing_state"]=>
         string(2) "RR"
       }
       ```
   
 * on the mail chimp the field stay blank

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘State Field (Select)’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-mailchimp/assets/icon.svg?rev=1495270)
 * [WP WooCommerce Mailchimp](https://wordpress.org/plugins/woocommerce-mailchimp/)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-mailchimp/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-mailchimp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-mailchimp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-mailchimp/reviews/)

## Tags

 * [billing_state](https://wordpress.org/support/topic-tag/billing_state/)
 * [state field](https://wordpress.org/support/topic-tag/state-field/)

 * 6 replies
 * 4 participants
 * Last reply from: [pfurlan](https://wordpress.org/support/users/pfurlan/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/state-field-select/#post-6807028)
 * Status: not resolved