0

I'm currently working on an e-commerce site that uses WooCommerce, and the client wants to change the price filter from the existing range slider to the two inputs. By default, WooCommerce creates it as two inputs, then uses jQuery UI to replace it with a slider to make it accessible.

Now, I can do this by commenting out the appropriate wp_enqueue_script call in WooCommerce itself, but this will obviously get overwritten when WooCommerce gets updated.

As far as I can tell, the following should work when inserted into the functions.php for the theme:

function remove_slider() {
    wp_dequeue_script( 'wc-price-slider' );
}
add_filter( 'wp_enqueue_scripts', 'remove_slider' );

This is consistent with what I've seen in quite a few blog posts that turned up in a Google search. However, it's just not working. Any idea what I need to do to achieve this?

closed as off-topic by Mayeenul Islam, Pieter Goosen, Robert hue, Mark Kaplun, cybmeta Feb 18 '15 at 16:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

2

This script is localized and registered, so you're going to need to use wp_deregister_script() instead of wp_dequeue_script(). Also, you need to use the function add_action() instead of add_filter() for this. Think of add_action as a way to inject run-able code into an existing function and think of add_filter as a way to manipulate the returned output of an existing function.

function remove_slider() {
     wp_deregister_script( 'wc-price-slider' );
}    
add_filter( 'wp_enqueue_scripts', 'remove_slider' );

the above works on my current install.

Not the answer you're looking for? Browse other questions tagged or ask your own question.