Answer the question
In order to leave comments, you need to log in
How to get max price of all products in woocommerce?
I use this code
global $wpdb;
$minsql = "SELECT MIN(meta_value) FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value<>0 AND meta_value IS NOT NULL";
$maxsql = "SELECT MAX(meta_value) FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value<>0 AND meta_value IS NOT NULL";
$minPrice = $wpdb->get_var($wpdb->prepare($minsql, '_price'));
$maxPrice = $wpdb->get_var($wpdb->prepare($maxsql, '_price'));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question