get_filtered_price();
}
};
return $filter->_get_filtered_price();
}
// always on database
global $wpdb;
$sql = "
SELECT MIN(min_price) as min_price, MAX(max_price) as max_price
FROM {$wpdb->wc_product_meta_lookup}
WHERE product_id IN (
SELECT ID FROM {$wpdb->posts}
WHERE {$wpdb->posts}.post_type = 'product'
AND {$wpdb->posts}.post_status = 'publish'
)";
return $wpdb->get_row($sql);
}
function adminz_min_max_price($atts) {
$filtered_price = adminz_get_filtered_price();
// Thiết lập giá trị min và max để sử dụng trong HTML
$min_price = $filtered_price->min_price ?? 0;
$max_price = $filtered_price->max_price ?? 100;
// -------------- START COPY FROM WOOCOMMERCE -------
// Round values to nearest 10 by default.
$step = max(apply_filters('woocommerce_price_filter_widget_step', 10), 1);
// Check to see if we should add taxes to the prices if store are excl tax but display incl.
$tax_display_mode = get_option('woocommerce_tax_display_shop');
if (wc_tax_enabled() && !wc_prices_include_tax() && 'incl' === $tax_display_mode) {
$tax_class = apply_filters('woocommerce_price_filter_widget_tax_class', ''); // Uses standard tax class.
$tax_rates = WC_Tax::get_rates($tax_class);
if ($tax_rates) {
$min_price += WC_Tax::get_tax_total(WC_Tax::calc_exclusive_tax($min_price, $tax_rates));
$max_price += WC_Tax::get_tax_total(WC_Tax::calc_exclusive_tax($max_price, $tax_rates));
}
}
$min_price = apply_filters('woocommerce_price_filter_widget_min_amount', floor($min_price / $step) * $step);
$max_price = apply_filters('woocommerce_price_filter_widget_max_amount', ceil($max_price / $step) * $step);
// -------------- END COPY FROM WOOCOMMERCE -------
ob_start();
$current_min = isset($_GET['min_price']) ? $_GET['min_price'] : $min_price;
$current_max = isset($_GET['max_price']) ? $_GET['max_price'] : $max_price;
?>