• Resolved indextwo

    (@indextwo)


    When I first installed and activated this plugin, it didn’t appear to work. I checked the source of my page and noticed that the script /js/add-to-cart-variation.js hadn’t been enqueued; however the localised parameters (AddToCartAjax) were being added.

    I think the issue is that the ID used for the script (add-to-cart-variation) is actually being used by WooCommerce for their add-to-cart-variation.js script.

    I changed the ID of the script in the following function at around line 94:

    function ajax_add_to_cart_script() {
    		wp_enqueue_script('add-to-cart-variation_ajax', plugins_url('/js/add-to-cart-variation.js', __FILE__), array('jquery'), false, true);
    		wp_localize_script('add-to-cart-variation_ajax', 'AddToCartAjax', array('ajaxurl' => admin_url('admin-ajax.php')));
    	}

    …and now it seems to enqueue without issue. You might want to make the ID a bit more unique, just to ensure it doesn’t conflict with anything else.

    https://www.ads-software.com/plugins/woocommerce-ajax-add-to-cart-for-variable-products/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Rishi Mehta

    (@rcreators)

    Hi,

    Thanks for the information. will update ids in next update. Working on more detailed features for next update.

    Thread Starter indextwo

    (@indextwo)

    Great – thanks for the swift reply. After making that small change, the plugin works perfectly.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need to change ID of enqueued script’ is closed to new replies.