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.
Hello
unfortunately the plugin does not have this feature
Is this feature on the roadmap for the plugin or will it get added in the foreseeable future?
Hello
Unfortunately not. because meta fields don’t have a specific structure
@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 …
@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.
@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 …