Woocommerce get billing state manually

To avoid that error, you have to add something in your function like:

add_filter( 'woocommerce_email_recipient_new_order', 'tm_destinatario_condicionado_wc', 10, 2 );
function tm_destinatario_condicionado_wc( $recipient, $order ) {

    // To avoid an error in backend
    if( ! is_a($order, 'WC_Order') ) return $recipient;

    $estados = array(
        'aguascalientes'        => 'AG',
        'baja-california'       => 'BC',
        // etc etc ...
    );

    // Get billing state 2 digits
    // This is what is causing the error
    $estado_siglas = $order->get_billing_state();

    // Get the keys of $estados by the value (wich is the 2 digit billing 
    // state) to get state name
    $estado_slug = array_search( $estado_siglas, $estados );

    // Gets the id of a taxonomy related to the state based on the name 
    // obtained from $estados theres a custon field containing the recipients
    $estado_id = get_term_by( 'slug', $estado_slug, 'estados' )->term_id;

    // get the custom field with the recipients
    $emails  = get_field( 'sucursal_email', 'estados_' . $estado_id ); 

    // Add the custom field content to the recipient
    $recipient .= ', ' . $emails; 

    return $recipient;
}

This should solve your issue definitively…

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)