Error: the 'ajax' option is not allowed for Select2 when joining the wseocommerce <select> element

any organ will help me spend too much time on this error, but no luck

Error: the 'ajax' option is not allowed for Select2 when connecting to an element.

this error appears in my developer console after upgrading woocommerce to version 3.0.3. This error does not work, some of the functions, such as could not add upsell and text field crosshairs, are marked.

When I change the subject, it disappears, and I cannot change my subject.

Please, help.

+4
source share
1 answer

- wordpress, .

1st , . WC Beta 2 Select2 V4. Select2 V4 Select2 V3 , , AJAX. WooCommerce , , HTML .

<input type="hidden" id="grant_access_id" name="grant_access_id" data-multiple="true" class="wc-product-search" style="width: 400px;" data-placeholder="<?php esc_attr_e( 'Search for a downloadable product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_downloadable_products_and_variations" />

<select id="grant_access_id" class="wc-product-search" name="grant_access_id[]" multiple="multiple" style="width: 400px;" data-placeholder="<?php esc_attr_e( 'Search for a downloadable product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_downloadable_products_and_variations"></select>

wordpress , select2 , select2 functions.php. script

add_action( 'admin_enqueue_scripts', 'remove_views_select2' );

function remove_views_select2($hook) {
    if ( ( $hook == 'post.php' || $hook == 'post-new.php' ) ) {
        wp_deregister_script( 'select2' );
        // wp_register_script( 'views-select2-script' , 'http://your-site.com/wp-content/plugins/meta-box/js/select2/select2.min.js', array('jquery'), 3.2);
    }
}

. ! 😉

+1

Source: https://habr.com/ru/post/1676724/


All Articles