Need to change ID of enqueued script
-
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 theiradd-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/
- The topic ‘Need to change ID of enqueued script’ is closed to new replies.