# Changing the list based on WPML Language

By default the plugin subscribes the user to the Mailchimp list you select on the settings screen.

For WPML users, you may want to customize the list based on the WPML language of the user when they completed the order. If so, you can use the ss_wc_mailchimp_subscribe_options hook to modify the Mailchimp subscribe options to set a language-specific list.

Below is an example of how to change the list based on the WPML language for the order:

/************ MAILCHIMP INTEGRATION HOOKS *********/
add_filter( 'ss_wc_mailchimp_subscribe_options'
    , 'ss_wc_mailchimp_change_list_based_on_language', 10 , 2 );
function ss_wc_mailchimp_change_list_based_on_language( $subscribe_options, $order_id ) {

    // Use ICL_LANGUAGE_CODE line below to use the wp-admin language.
    // $lang = ICL_LANGUAGE_CODE;
    // The line below retrieves the language of user for the WooCommerce order.
    // NOTE: In some cases the meta key below may be 'wpml_language' instead
    // of '_icl_current_language'
    $lang = get_post_meta( $order_id, '_icl_current_language', true );
    switch ($lang) {
        case 'en':
            $subscribe_options['list_id'] = '1234';
            break;
        default:
            $subscribe_options['list_id'] = '5678';
    }
    return $subscribe_options;
}

WP WooCommerce Mailchimp Pro (opens new window) includes an easy way to setup product-specific lists, interest groups and tags.

Last Updated: 9/22/2022, 8:18:23 PM