K
K
Konstantin2020-07-24 00:14:35
WordPress
Konstantin, 2020-07-24 00:14:35

How to connect your price filter in woocommerce?

I have my price filter design, how can I connect it to Woocommerce?

5f19fdadb0659072936176.jpeg

Preferably a standard feature.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin, 2020-07-30
@gradk

And so I figured it out myself.
1) Wooconnerce filters are located in the /wp-content/plugins/woocommerce/includes/widgets/ folder, copy the class-wc-widget-price-filter.php file and paste it into your theme, for example, in the inc folder (wp-content/ themes/grad_market/inc/)
2) Edit the previously copied file:
Rename the file, for example: price-widgets.php
Rename the function, for example:
class My_Widget_Price_Filter extends WC_Widget {
Next, at the end of the file, initialize the widget:

function register_price1_widget() {
    register_widget( 'My_Widget_Price_Filter' );
}
add_action( 'widgets_init', 'register_price1_widget' );

3) Next, in fuctions.php we connect this widget:
require get_template_directory() . '/inc/price-widgets.php';

4) Now for each input in the layout of the filter we write (the screen above, there is a field for min and maximum prices):
name="min_price" and, accordingly, name="max_price"
Example:
<input id="priceMin" name="min_price" class="min_price" value="5000"> -
<input id="priceMax" name="max_price" value="15000" class="min_price">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question