Viewing 6 replies - 1 through 6 (of 6 total)
  • +1!!!

    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

    (@anderly)

    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' => '[email protected]' );
    
        // 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 );

    Legend. I have installed as a snippet, will test and see if it works with next order (hopefully order isnt broken!!) ??

    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

    (@pfurlan)

    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.