Support » Plugin: Mailchimp for WooCommerce » ‘CONNECT ACCOUNT’ button does not work

  • Resolved techtiger

    (@techtiger)


    Hi there,

    When I click the ‘CONNECT ACCOUNT’ button on step 1 of 3 for ‘Add Mailchimp for WooCommerce’ nothing happens.

    The modal box that is supposed to display doesn’t appear.

    Please help!

    Thanks.

    • This topic was modified 1 year, 4 months ago by techtiger.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter techtiger

    (@techtiger)

    Uncaught TypeError: e.indexOf is not a function
    at S.fn.init.S.fn.load (jquery.min.js?ver=3.5.1:2)
    at mailchimp-woocommerce-admin.js?ver=2.5.1.21:4
    at mailchimp-woocommerce-admin.js?ver=2.5.1.21:779

    Seems to be an issue with /wp-content/plugins/mailchimp-for-woocommerce/admin/js/mailchimp-woocommerce-admin.js?ver=2.5.1.21

    Thread Starter techtiger

    (@techtiger)

    I see the plugin is made with jQuery 2.5.1. My staff member updated the code to work with jQuery 3.5 as per below:

    jQuery(document).ready(function(){

    jQuery.noConflict();
    jQuery( window ).load(function() {

    // show/hide optional settings
    var optionalSettings = false;
    jQuery(‘.optional-settings-button’).click(function () {
    if (optionalSettings) {
    jQuery(‘.optional-settings-content’).slideUp();
    jQuery(this).find(‘span’).removeClass(‘active’);
    optionalSettings = false;
    } else {
    jQuery(‘.optional-settings-content’).slideDown();
    jQuery(this).find(‘span’).addClass(‘active’);
    optionalSettings = true;
    }
    });

    // re-enable disable select input on audience settings submit
    jQuery(‘#mailchimp_woocommerce_options’).on(‘submit’, function() {
    jQuery(‘select[name=”mailchimp-woocommerce[mailchimp_list]”]’).prop(‘disabled’, false);
    });

    // load new log file on log select change
    jQuery(‘#log_file’).change(function (e) {
    e.preventDefault();
    // prevents Log Deleted notification to show up
    removeLogDeletedParamFromFormHttpRef();

    var data = {
    action:’mailchimp_woocommerce_load_log_file’,
    log_file: jQuery(‘#log_file’).val()
    };

    jQuery(‘#log-viewer #log-content’).css(“visibility”, “hidden”);
    jQuery(‘#log-viewer .spinner’).show().css(“visibility”, “visible”);

    jQuery.post(ajaxurl, data, function(response) {
    if (response.success) {
    jQuery(‘#log-content’).html(response.data)
    }
    else {
    jQuery(‘#log-content’).html(‘Error: ‘ + response.data)
    }

    jQuery(‘#log-viewer .spinner’).hide().css(“visibility”, “hidden”);
    jQuery(‘#log-viewer #log-content’).css(“visibility”, “visible”);
    });
    });

    jQuery(‘#mailchimp-log-pref’).change(function (e) {
    e.preventDefault();
    // prevents Log Deleted notification to show up
    removeLogDeletedParamFromFormHttpRef();

    jQuery(‘#mailchimp_woocommerce_options’).submit();
    });

    // Remove log_deleted param from _wp_http_referer hidden input
    function removeLogDeletedParamFromFormHttpRef() {
    var currentFormRefererUrl = jQuery(‘input[name=”_wp_http_referer”]’).val();
    jQuery(‘input[name=”_wp_http_referer”]’).val(currentFormRefererUrl.replace(‘&log_removed=1’, ”))
    }

    // copy log button
    jQuery(‘.mc-woocommerce-copy-log-button’).click(function (e) {
    e.preventDefault();
    var copyText = jQuery(‘#log-content’);
    var jQuerytemp = jQuery(“<textarea>”);
    jQuery(“body”).append(jQuerytemp);
    jQuerytemp.val(jQuery(copyText).text()).select();
    / Copy the text inside the text field /
    document.execCommand(“copy”);
    jQuerytemp.remove();
    jQuery(‘.mc-woocommerce-copy-log-button span.clipboard’).hide();
    jQuery(‘.mc-woocommerce-copy-log-button span.yes’).show();
    });

    jQuery(‘.mc-woocommerce-copy-log-button’).mouseleave(function (e) {
    jQuery(‘.mc-woocommerce-copy-log-button span.clipboard’).show();
    jQuery(‘.mc-woocommerce-copy-log-button span.yes’).hide();
    });

    // delete log button
    jQuery(‘.delete-log-button’).click(function (e) {
    e.preventDefault();

    Swal.fire({
    title: phpVars.l10n.are_you_sure,
    text: phpVars.l10n.log_delete_subtitle,
    type: ‘warning’,
    showCancelButton: true,
    confirmButtonColor: ‘#3085d6’,
    cancelButtonColor: ‘#d33’,
    confirmButtonText: phpVars.l10n.log_delete_confirm,
    cancelButtonText: phpVars.l10n.no_cancel,
    customClass: {
    confirmButton: ‘button button-primary tab-content-submit disconnect-button’,
    cancelButton: ‘button button-default mc-woocommerce-resync-button disconnect-button’
    },
    buttonsStyling: false,
    reverseButtons: true,

    }).then((result) => {
    if (result.value) {
    var data = {
    action:’mailchimp_woocommerce_delete_log_file’,
    log_file: jQuery(‘#log_file’).val()
    };

    jQuery(‘#log-viewer #log-content’).css(“visibility”, “hidden”);
    jQuery(‘#log-viewer .spinner’).show().css(“visibility”, “visible”);

    jQuery.post(ajaxurl, data, function(response) {
    console.log(‘deleted log file’, data.log_file);
    if (response.success) {
    window.location.reload();
    }
    jQuery(‘#log-viewer .spinner’).hide().css(“visibility”, “hidden”);
    jQuery(‘#log-viewer #log-content’).css(“visibility”, “visible”);
    });
    }
    })
    });

    jQuery(‘.mc-woocommerce-resync-button’).click(function(e) {
    e.preventDefault();
    Swal.fire({
    title: phpVars.l10n.resync_in_progress,
    onBeforeOpen: () => {
    Swal.showLoading()
    }
    });
    var form = jQuery(‘#mailchimp_woocommerce_options’);
    var data = form.serialize();
    data+=”&mailchimp_woocommerce_resync=1″
    return jQuery.ajax({type: “POST”, url: form.attr(‘action’), data: data}).done(function(data) {
    window.location.reload();
    }).fail(function(xhr) {
    Swal.hideLoading();
    Swal.showValidationMessage(phpVars.l10n.resync_failed);
    });
    });

    /*
    * Shows dialog on store disconnect
    * Change wp_http_referer URL in case of store disconnect
    */
    var mailchimp_woocommerce_disconnect_done = false;
    jQuery(‘#mailchimp_woocommerce_disconnect’).click(function (e){
    var me = jQuery(this);

    // this is to trigger the event even after preventDefault() is issued.
    if (mailchimp_woocommerce_disconnect_done) {
    mailchimp_woocommerce_disconnect_done = false; // reset flag
    return; // let the event bubble away
    }

    e.preventDefault();

    const swalWithBootstrapButtons = Swal.mixin({
    customClass: {
    confirmButton: ‘button button-primary tab-content-submit disconnect-confirm’,
    cancelButton: ‘button button-default mc-woocommerce-resync-button disconnect-button’
    },
    buttonsStyling: false,
    })

    swalWithBootstrapButtons.fire({
    title: phpVars.l10n.are_you_sure,
    text: phpVars.l10n.store_disconnect_subtitle,
    type: ‘warning’,
    showCancelButton: true,
    confirmButtonColor: ‘#3085d6’,
    cancelButtonColor: ‘#d33’,
    confirmButtonText: phpVars.l10n.store_disconnect_confirm,
    cancelButtonText: phpVars.l10n.no_cancel,
    reverseButtons: true,
    }).then((result) => {
    if (result.value) {
    var query = window.location.href.match(/^(.*)\&/);
    if (query){
    history.replaceState({}, “”, query[1]);
    jQuery(‘input[name=_wp_http_referer]’).val(query[1]);
    }
    try {
    mailchimp_woocommerce_disconnect_done = true;
    var form = jQuery(‘#mailchimp_woocommerce_options’);
    var data = form.serialize();
    data+=”&mailchimp_woocommerce_disconnect_store=1″

    Swal.fire({
    title: phpVars.l10n.store_disconnect_in_progress,
    onBeforeOpen: () => {
    Swal.showLoading()
    }
    });

    return jQuery.ajax({type: “POST”, url: form.attr(‘action’), data: data }).done(function(data) {
    window.location.reload();
    }).fail(function(xhr) {
    Swal.hideLoading();
    Swal.showValidationMessage(“Could not delete store.”);
    });
    } catch (e) {
    console.error(‘clicking event for disconnect failed’, e);
    }
    }
    })
    });

    /*
    * Change wp_http_referer URL in case of in-wizard tab change
    */
    var mailchimp_woocommerce_submit_done = false;
    jQuery(‘#mailchimp_woocommerce_options .tab-content-submit:not(.oauth-connect):not(#mc-woocommerce-support-form-submit)’).click(function(e){
    // this is to trigger the event even after preventDefault() is issued.
    if (mailchimp_woocommerce_submit_done) {
    mailchimp_woocommerce_submit_done = false; // reset flag
    return; // let the event bubble away
    }
    e.preventDefault();

    if (jQuery(‘input[name=mailchimp_woocommerce_wizard_on]’).val() == 1) {
    var query = window.location.href.match(/^(.*)\&/);
    if (query){
    history.replaceState({}, “”, query[1]);
    jQuery(‘input[name=_wp_http_referer]’).val(query[1]);
    }
    }
    mailchimp_woocommerce_submit_done = true;
    e.target.click();

    });

    // Mailchimp OAuth connection (tab “connect”)
    jQuery(‘#mailchimp_woocommerce_options #mailchimp-oauth-connect’).click(function(e){
    var token = ”;
    var startData = {action:’mailchimp_woocommerce_oauth_start’};
    jQuery(‘#mailchimp-oauth-api-key-valid’).hide();
    jQuery(‘#mailchimp-oauth-error’).hide();
    jQuery(‘#mailchimp-oauth-waiting’).show();

    jQuery.post(ajaxurl, startData, function(startResponse) {
    if (startResponse.success) {
    token = JSON.parse(startResponse.data.body).token;
    openOAuthPopup(token);
    }
    else {
    console.log(“Error: start response:”,startResponse);
    }
    });
    });

    function openOAuthPopup(token) {
    var domain = ‘https://woocommerce.mailchimpapp.com&#8217;;
    var options = {
    path: domain+’/auth/start/’+token,
    windowName: ‘Mailchimp For WooCommerce OAuth’,
    height: 800,
    width: 1035,
    };
    var left = (screen.width – options.width) / 2;
    var top = (screen.height – options.height) / 4;
    var window_options = ‘toolbar=no, location=no, directories=no, ‘ +
    ‘status=no, menubar=no, scrollbars=no, resizable=no, ‘ +
    ‘copyhistory=no, width=’ + options.width +
    ‘, height=’ + options.height + ‘, top=’ + top + ‘, left=’ + left +
    ‘, domain=’+domain.replace(‘https://&#8217;, ”);

    // open Mailchimp OAuth popup
    var popup = window.open(options.path, options.windowName, window_options);

    if (popup == null) {
    window.clearInterval(oauthInterval);
    const swalWithBootstrapButtons = Swal.mixin({
    customClass: {
    confirmButton: ‘button button-primary tab-content-submit disconnect-button’,
    cancelButton: ‘button button-default mc-woocommerce-resync-button disconnect-button’
    },
    buttonsStyling: false,
    })

    swalWithBootstrapButtons.fire({
    type : ‘error’,
    title: phpVars.l10n.login_popup_blocked,
    text: phpVars.l10n.login_popup_blocked_desc,
    footer: ‘How to Enable Pop-ups in Your Browser‘,
    showCancelButton: true,
    cancelButtonColor: ‘#d33’,
    confirmButtonColor: ‘#7fad45’,
    cancelButtonText: phpVars.l10n.no_cancel,
    confirmButtonText: phpVars.l10n.try_again,
    reverseButtons: true
    }).then((result) => {
    if (result.value) {
    openOAuthPopup(token);
    }
    });
    }
    else {
    var oauthInterval = window.setInterval(function(){
    if (popup.closed) {
    // clear interval
    window.clearInterval(oauthInterval);

    // hide/show messages
    jQuery(‘#mailchimp-oauth-error’).hide();
    jQuery(‘#mailchimp-oauth-waiting’).hide();
    jQuery(‘#mailchimp-oauth-connecting’).show();

    var checkData = {
    action:’mailchimp_woocommerce_oauth_status’,
    url: domain + ‘/api/status/’ + token,
    };

    // ping status to check if auth was accepted
    jQuery.post(ajaxurl, checkData).done(function(statusData) {
    if (statusData.data.status == “accepted”) {
    // call for finish endpoint to retrieve access_token
    var finishData = {
    action: ‘mailchimp_woocommerce_oauth_finish’,
    token: token
    }
    jQuery.post(ajaxurl, finishData, function(finishResponse) {
    if (finishResponse.success) {
    // hide/show messages
    jQuery(‘#mailchimp-oauth-error’).hide();
    jQuery(‘#mailchimp-oauth-connecting’).hide();
    jQuery(‘#mailchimp-oauth-connected’).show();

    // get access_token from finishResponse and fill api-key field value including data_center
    var accessToken = JSON.parse(finishResponse.data.body).access_token + ‘-‘ + JSON.parse(finishResponse.data.body).data_center
    jQuery(‘#mailchimp-woocommerce-mailchimp-api-key’).val(accessToken);

    // always go to next step on success, so change url of wp_http_referer
    if (jQuery(‘input[name=mailchimp_woocommerce_wizard_on]’).val() == 1) {
    var query = window.location.href.match(/^(.*)\&/);
    if (query){
    history.replaceState({}, “”, query[1]);
    jQuery(‘input[name=_wp_http_referer]’).val(query[1]);
    }
    }
    // submit api_key/access_token form
    jQuery(‘#mailchimp_woocommerce_options’).submit();
    }
    else {
    console.log(‘Error calling OAuth finish endpoint. Data:’, finishResponse);
    }
    });
    }
    else {
    jQuery(‘#mailchimp-oauth-connecting’).hide();
    jQuery(‘#mailchimp-oauth-error’).show();
    console.log(‘Error calling OAuth status endpoint. No credentials provided at login popup? Data:’, statusData);
    }
    });
    }
    }, 250);
    }
    // While the popup is open, wait. when closed, try to get status=accepted
    }

    // Remove Initial Sync Banner oon dismiss
    jQuery(‘#setting-error-mailchimp-woocommerce-initial-sync-end .notice-dismiss’).click(function(e){
    jQuery.get(phpVars.removeReviewBannerRestUrl, [], function(response){
    console.log(response);
    });
    });

    jQuery(‘#comm_box_switch’).change(function (e){
    var switch_button = this;
    var opt = this.checked ? 1 : 0;

    var data = {
    action: ‘mailchimp_woocommerce_communication_status’,
    opt: opt
    }

    jQuery(‘.comm_box_status’).hide();
    jQuery(‘#comm_box_status_’ + opt).show();

    jQuery.post(ajaxurl, data, function(response) {
    if (response.success) {
    jQuery(‘#mc-comm-save’).html(response.data);
    jQuery(‘#mc-comm-save’).css(‘color’, ‘#628735’).show().fadeOut(3000);
    switch_button.checked = opt;
    }
    else {
    jQuery(‘#mc-comm-save’).html(response.data.error);
    jQuery(‘#mc-comm-save’).css(‘color’, ‘red’).show().fadeOut(3000);
    switch_button.checked = 1 – opt;
    jQuery(‘.comm_box_status’).hide();
    jQuery(‘#comm_box_status_’ + (1 – opt)).show();
    }
    });
    });
    // communications box radio ajax call
    jQuery(‘input.comm-box-input’).change(function(e){
    var data = {
    action: ‘mailchimp_woocommerce_communication_status’,
    opt: this.value
    }
    var opt = this.value;

    jQuery.post(ajaxurl, data, function(response) {
    if (response.success) {
    jQuery(‘#mc-comm-save-‘+opt).html(response.data);
    jQuery(‘#mc-comm-save-‘+opt).css(‘color’, ‘#628735’).show().fadeOut(5000);
    jQuery(‘#swi’).checked = true;
    }
    else {
    jQuery(‘#mc-comm-save-‘+opt).html(response.data.error);
    jQuery(‘#mc-comm-save-‘+opt).css(‘color’, ‘red’).show().fadeOut(5000);
    jQuery(‘#mc-comm-input-‘+response.data.opt).prop(‘checked’, true);
    jQuery(‘#swi’).checked = false;
    }
    });
    });

    // Account create functionality
    jQuery(‘#mc-woocommerce-create-account-next’).unbind().click(function (e) {
    var next_button = jQuery(this);
    var spinner = jQuery(this).next(‘.spinner’);
    spinner.css(‘visibility’, ‘visible’)

    jQuery(‘.mc-woocommerce-create-account-step-error > p’).hide();
    jQuery(‘#username_suggestion’).css(‘visibility’, ‘hidden’);
    var email = jQuery(‘input#email’);
    var username = jQuery(‘input#username’);

    var isValid= true;

    if (! email[0].checkValidity()) {
    jQuery(‘#email_error’).show();
    isValid= false;
    }
    else {
    jQuery(‘#email_error’).hide();
    }

    if (! username[0].checkValidity()) {
    jQuery(‘#username_invalid_error’).show();
    spinner.css(‘visibility’, ‘hidden’);
    }
    else {
    jQuery(‘#username_invalid_error’).hide();
    var data = {
    action:’mailchimp_woocommerce_create_account_check_username’,
    username: username.val(),
    };

    jQuery.post(ajaxurl, data, function(response) {
    if (response.success) {
    jQuery(‘#username_exists_error’).hide();
    if ( isValid == true) {
    spinner.css(‘visibility’, ‘hidden’);
    jQuery(‘.mc-woocommerce-settings’).css(‘height’, ‘900px’);
    jQuery(‘#mc-woocommerce-create-account-step-1’).hide();
    jQuery(‘#mc-woocommerce-create-account-step-2’).show();
    jQuery(‘#step_count’).html(‘2’);
    }
    }
    else {
    jQuery(‘#username_exists_error’).show();
    jQuery(‘#username_suggestion’).css(‘visibility’, ‘visible’);
    jQuery(‘#username_suggestion span’).html(response.data.suggestion);
    spinner.css(‘visibility’, ‘hidden’);
    }
    });
    }
    });

    jQuery(‘#mc-woocommerce-create-account-prev’).click(function () {
    jQuery(‘#mc-woocommerce-create-account-step-1’).show();
    jQuery(‘#mc-woocommerce-create-account-step-2’).hide();
    jQuery(‘#step_count’).html(‘1’);

    });

    jQuery(‘#mc-woocommerce-create-account-go’).unbind().click(function () {
    var email = jQuery(‘input#email’);
    var firstName = jQuery(‘input#first_name’);
    var lastName = jQuery(‘input#last_name’);
    var org = jQuery(‘input#org’);
    var timezone = jQuery(‘select#timezone’);

    var username = jQuery(‘input#username’);

    var address = jQuery(‘input#address’);
    var address2 = jQuery(‘input#address2’);
    var city = jQuery(‘input#city’);
    var state = jQuery(‘input#state’);
    var zip = jQuery(‘input#zip’);
    var country = jQuery(‘select#country’);
    var phone = jQuery(‘input#phone’);

    var isValid = true;

    var spinner = jQuery(this).next(‘.spinner’);
    spinner.css(‘visibility’, ‘visible’);

    if (! address[0].checkValidity() || ! address2[0].checkValidity()) {
    jQuery(‘#address_error’).show();
    isValid= false;
    }
    else {
    jQuery(‘#address_error’).hide();
    }

    if (! city[0].checkValidity()) {
    jQuery(‘#city_error’).show();
    isValid= false;
    }
    else {
    jQuery(‘#city_error’).hide();
    }

    if (! state[0].checkValidity()) {
    jQuery(‘#state_error’).show();
    isValid= false;
    }
    else {
    jQuery(‘#state_error’).hide();
    }

    if (! zip[0].checkValidity()) {
    jQuery(‘#zip_error’).show();
    isValid= false;
    }
    else {
    jQuery(‘#zip_error’).hide();
    }

    if (! country[0].checkValidity()) {
    jQuery(‘#country_error’).show();
    isValid= false;
    }
    else {
    jQuery(‘#country_error’).hide();
    }

    if (! phone[0].checkValidity()) {
    jQuery(‘#phone_error’).show();
    isValid= false;
    }
    else {
    jQuery(‘#phone_error’).hide();
    }

    if (! timezone[0].checkValidity()) {
    jQuery(‘#timezone_error’).show();
    isValid= false;
    }
    else {
    jQuery(‘#timezone_error’).hide();
    }

    if (isValid) {
    var data = {
    action:’mailchimp_woocommerce_create_account_signup’,
    data: {
    email: email.val(),
    first_name: firstName.val(),
    last_name: lastName.val(),
    org: org.val(),
    timezone: timezone.val(),
    username: username.val(),
    address: {
    address1: address.val(),
    city: city.val(),
    state: state.val(),
    zip: zip.val(),
    country: country.val()
    }
    },
    };

    // add optional address 2 only if it’s filled out
    if (address2.val() != ”) {
    data.data.address.address2 = address2.val();
    }

    jQuery.post(ajaxurl, data, function(response) {
    if (response.success) {
    jQuery(‘#connecting’).show();
    spinner.css(‘visibility’, ‘hidden’);

    // get access_token and fill api-key field value including data_center
    var accessToken = response.data.data.oauth_token + ‘-‘ + response.data.data.dc

    jQuery(‘#mailchimp-woocommerce-mailchimp-api-key’).val(accessToken);

    // always go to next step on success, so change url of wp_http_referer
    if (jQuery(‘input[name=mailchimp_woocommerce_wizard_on]’).val() == 1) {
    var query = window.location.href.match(/^(.*)\&/);
    if (query){
    history.replaceState({}, “”, query[1]);
    jQuery(‘input[name=_wp_http_referer]’).val(query[1]);
    }
    }
    // submit api_key/access_token form
    jQuery(‘#mailchimp_woocommerce_options’).submit();
    }
    }).fail(function (err) {
    console.log(‘FAIL:’ , err);
    });
    }
    else {
    spinner.css(‘visibility’, ‘hidden’)
    }
    });

    jQuery(‘#username_suggestion span’).click(function (){
    jQuery(‘input#username’).val(jQuery(this).html());
    });

    jQuery(‘#mc-woocommerce-create-account-step-1′).keypress(function(event){
    event.stopPropagation();
    var keycode = (event.keyCode ? event.keyCode : event.which);
    if ( keycode == ’13’ ){
    jQuery(“#mc-woocommerce-create-account-next”).click();
    }
    });

    jQuery(‘#mc-woocommerce-create-account-step-2′).keypress(function(event){
    event.stopPropagation();
    var keycode = (event.keyCode ? event.keyCode : event.which);
    if ( keycode == ’13’ ){
    jQuery(“#mc-woocommerce-create-account-go”).click();
    }
    });

    jQuery(‘a#mc-woocommerce-support-form-submit’).click(function (e) {
    var accountId = jQuery(‘input#account_id’);
    var storeId = jQuery(‘input#store_id’);
    var email = jQuery(‘input#email’);
    var firstName = jQuery(‘input#first_name’);
    var lastName = jQuery(‘input#last_name’);
    var subject = jQuery(‘input#subject’);
    var message = jQuery(‘textarea#message’);

    var isValid = true;

    var spinner = jQuery(this).next(‘.spinner’);
    spinner.css(‘visibility’, ‘visible’);
    jQuery(‘#success’).hide();
    jQuery(‘#error’).hide();

    if (! email[0].checkValidity()) {
    jQuery(‘#email_error’).show();
    isValid= false;
    }
    else {
    jQuery(‘#email_error’).hide();
    }

    if (! firstName[0].checkValidity()) {
    jQuery(‘#first_name_error’).show();
    isValid= false;
    }
    else {
    jQuery(‘#first_name_error’).hide();
    }

    if (! lastName[0].checkValidity()) {
    jQuery(‘#last_name_error’).show();
    isValid= false;
    }
    else {
    jQuery(‘#last_name_error’).hide();
    }

    if (! subject[0].checkValidity()) {
    jQuery(‘#subject_error’).show();
    isValid= false;
    }
    else {
    jQuery(‘#subject_error’).hide();
    }

    if (! message[0].checkValidity()) {
    jQuery(‘#message_error’).show();
    isValid= false;
    }
    else {
    jQuery(‘#message_error’).hide();
    }

    if (isValid) {
    var data = {
    action:’mailchimp_woocommerce_support_form’,
    data: {
    email: email.val(),
    first_name: firstName.val(),
    last_name: lastName.val(),
    subject: subject.val(),
    message: message.val(),
    account_id: accountId.val(),
    store_id: storeId.val(),
    },
    };

    Swal.fire({
    title: phpVars.l10n.support_message_sending,
    html: phpVars.l10n.please_wait,
    onBeforeOpen: () => {
    Swal.showLoading();
    jQuery.post(ajaxurl, data, function(response) {
    Swal.hideLoading();
    if (response.success) {
    location.hash = ‘#mc-woocommerce-support-form-button’;
    jQuery(‘#success’).show();
    subject.val(”);
    message.val(”);
    spinner.css(‘visibility’, ‘hidden’);
    Swal.fire({
    icon: ‘success’,
    timer: 2000,
    title: phpVars.l10n.support_message_ok,
    html: phpVars.l10n.support_message_desc,
    });
    } else if (response.data.error) {
    jQuery(‘#error’).show();
    spinner.css(‘visibility’, ‘hidden’);
    }
    }).fail(function (err) {
    Swal.fire({
    icon: ‘error’,
    timer: 2000,
    title: ‘Oops, something went wrong!’,
    html: err,
    });
    });
    },
    });
    }
    else {
    spinner.css(‘visibility’, ‘hidden’)
    }
    });

    var checkbox_label = phpVars.l10n.subscribe_newsletter;
    var label = checkbox_label;
    jQuery(‘#mailchimp-woocommerce-newsletter-checkbox-label’).keyup(function(event){
    event.stopPropagation();
    if (jQuery(‘#mailchimp-woocommerce-newsletter-checkbox-label’).val() == “”) {
    label = checkbox_label;
    }
    else label = jQuery(‘#mailchimp-woocommerce-newsletter-checkbox-label’).val();
    jQuery(‘#preview-label’).html(label);
    });

    switchPreviewCheckbox(phpVars.current_optin_state)
    jQuery(‘input[type=”radio”]’).change(function(event){
    event.stopPropagation();
    switchPreviewCheckbox(event.currentTarget.value);
    });

    function switchPreviewCheckbox(currentState) {
    switch (currentState) {
    case ‘check’:
    jQuery(‘.mailchimp-newsletter’).show();
    jQuery(‘.mailchimp-newsletter input’).prop( “checked”, true );
    break;
    case ‘uncheck’:
    jQuery(‘.mailchimp-newsletter’).show();
    jQuery(‘.mailchimp-newsletter input’).prop( “checked”, false );
    break;
    case ‘hide’:
    jQuery(‘.mailchimp-newsletter’).hide();
    break;
    default:
    break;
    }
    }
    });

    })

    Plugin Author ryanhungate

    (@ryanhungate)

    @techtiger yes – thanks for bringing this up – we’ll make sure to make this compatible with the latest jquery in a future release… appreciate you bringing this up.

    Hi, I’ve been exposed to the same issue.

    @ryanhungate Is there any news about the release date of the update that is suppose to change the jquery version?

    @techtiger Could you please tell me in which file did you put the code you mentionned?

    Thanks

    @ryanhungate hello, I’m having the same exact issue. Tried changing the theme and deactivate plugins but cannot find a solution.

    @techtiger did you place this code in mailchimp-for-woocommerce/admin/js/mailchimp-commerce-admin.js? I tried it but that still didn’t quite do the trick.

    Thanks for your help!

    @lgrech I just figured out how to get the “Connect Account” button to work. Obviously, with an update to the plugin it will wipe out this code so hopefully this will get added into the newest version. I updated the following line within the plugin files:
    mailchimp-for-woocommerce/admin/js/mailchimp-commerce-admin.js

    The line that reads:
    $( window ).load(function() {
    I updated to:
    $(window).on(‘load’,function(){

    I found this advice here for a totally different deal but same error here: https://stackoverflow.com/questions/44604167/how-to-fix-the-jquery-url-indexof-function-not-defined-at-jquery-fn-init-jquery/44604259
    as far as the “load”, it has changed from the way it is coded in the plugin, I believe, the way it is now is deprecated and doesn’t work. Once I updated that line, the connect button worked.

    I tried the code above but the single quote is the wrong one so it kind of messed things up copy and pasting from there.

    • This reply was modified 1 year, 1 month ago by girdy74.
    • This reply was modified 1 year, 1 month ago by girdy74.
    voxoff

    (@voxoff)

    Hi guys any news about this issue im experiencing the same issue but i have this error in the Javascript console

    Uncaught TypeError: Cannot read properties of null (reading 'nextSibling')
        at Module.<anonymous> (index.js?ver=2.5.1:2)
        at Module.278 (index.js?ver=2.5.1:2)
        at a (index.js?ver=2.5.1:2)
        at wc.app.0 (index.js?ver=2.5.1:2)
        at index.js?ver=2.5.1:2
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘‘CONNECT ACCOUNT’ button does not work’ is closed to new replies.