Signup Form that adds customer to MailChimp, redirects to checkout, and fills in form data

I got help with this, the fix involved two functions in functions.php and one plugin.

The functions:

// Add to Cart for optin Form

add_action( 'template_redirect', 'website_add_to_cart_on_custom_page');
 
function website_add_to_cart_on_custom_page(){
 
    if( is_page( 'homepagee' ) ) { // is a page slug
 
        WC()->cart->add_to_cart( 18074 ); // add to cart product with ID
 
    }
 
}


// Autofill checkout fields from URL
 
add_filter( 'woocommerce_checkout_fields' , 'website_prefill_checkout_fields');
  
function website_prefill_checkout_fields ( $checkout_fields ) {
  
    /**
     * Query string fields to populate in checkout,
     *
     * Ex.
     * 'fname' => is query parameter name,
     * 'billing_first_name' => matching field of checkout 
     *
     * You can add other fields in the same way
     */
    $query_fields = array(
         
        'fname' => 'billing_first_name',
        'lname' => 'billing_last_name',
        'email' => 'billing_email',
        'phone' => 'billing_phone',
    );
 
    // We will loop the above array to check if the field exists in URL or not.
    // If it exists we will add it to the checkout field's default value
 
    foreach ( $query_fields as $field_slug => $match_field ) {
         
        // Check if it is in URL or not, An not empty.
        if ( isset( $_GET[ $field_slug ] ) && ! empty( $_GET[ $field_slug ] ) ) {
 
            // Sanitize the value and store it in a variable.
            $field_value = sanitize_text_field( $_GET[ $field_slug ] );
 
            // Check if match field exists in checkout form or not.
            if( isset( $checkout_fields['billing'][ $match_field ] ) ){
 
                // Assign the pre-fill value to checkout field
                $checkout_fields['billing'][ $match_field ]['default'] = $field_value;
            }
        }       
    }
 
 
    // Return the fields
    return $checkout_fields;
}

add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 );

The plugin we used was https://wordpress.org/plugins/mailchimp-for-wp/ and under the Form > Form Behaviour in this section we selected ‘Yes’ for the “Hide form after a successful sign-up?” and then added a url in the “Redirect to URL after successful sign-ups” field.

In that field, we followed the following format:

https://domain.com/checkout/?fname={data key="FNAME"}&lname={data key="LNAME"}&email={data key="EMAIL"}&phone={data key="PHONE"} 

Hopefully this helps someone down the road.

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