• Resolved nielsjvd

    (@nielsjvd)


    Hello,

    When I use the metafields slider option. The slider only displays 0 to 100 while the metafields are filled with numbers ranging from 0 to 1330.

    Is there a possible fix or workaround?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support mediawebster

    (@mediawebster)

    Hello

    Please read docs ( https://c2n.me/4bcgEUr.png ) – https://products-filter.com/extencion/woocommerce-filter-by-meta-fields/ – and set your range on additional options

    Thread Starter nielsjvd

    (@nielsjvd)

    Thanks for your response.
    The problem with this option is that the values have to be predefined.

    For example height:
    We get our products dynamically from all kind of different stores.
    So when a new product is added with a new max height. We want the range to change automatically.
    So we don’t have to check every day if there is a new min or max value.

    Plugin Support mediawebster

    (@mediawebster)

    Hello

    unfortunately the plugin does not have this feature

    Thread Starter nielsjvd

    (@nielsjvd)

    Is this feature on the roadmap for the plugin or will it get added in the foreseeable future?

    Plugin Support mediawebster

    (@mediawebster)

    Hello
    Unfortunately not. because meta fields don’t have a specific structure

    Plugin Author RealMag777

    (@realmag777)

    @nielsjvd

    Hello, thank you for the signal, I added it to the task list, this task can be resolved in future by adding action key instead of text like ‘0-100’. Action which can be placed into functions.php file will return prepared real range which data will be taken from meta fields by function get. But what will be open here – logic how to take min and max values, here not exists one-stop solution, and customer will have to resolve it self …

    Thread Starter nielsjvd

    (@nielsjvd)

    @realmag777 The solution is not hard at all.
    I solved it by adding a cron job instead of a hook. I just added the following

    
    $width_max = "";
    $width_min = "0";
    $args = array(
        'post_type' => 'product',
        'posts_per_page' => 1,
        'meta_query' => array(
            array(
                'key'     => '_width',
                'value'   => '',
                'compare' => '!=',
            )
        ),
        'orderby' => 'meta_value_num',
        'order' => 'DESC' 
    );
    $loop = new WP_Query( $args );
    $new_counter = 0;
    if ( $loop->have_posts() ) {
        while ( $loop->have_posts() ) : $loop->the_post();
        $id = get_the_ID();
        $new_counter++;
        $width_max = get_post_meta($id, '_width', true);
        endwhile;
    }
    $options = get_option('woof_settings');
    $options['_width']['range'] = $width_min.'^'.$width_max;
    update_option('woof_settings', $options);
    

    The best practice here is probably to add this functionality to a hook that gets fired everytime a product is edited. But since we get around 3000 new products every morning I decided to add a cronjob that fires after the retrieval of products is finished

    • This reply was modified 5 years ago by nielsjvd.
    Plugin Author RealMag777

    (@realmag777)

    @nielsjvd

    Thank you for cooperation! Yes, cron for 3K new products here is necessary, we will include it in documentation when the feature will be released …

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Meta fields slider’ is closed to new replies.