تابع wc_get_min_max_price_meta_query دریافت کمترین و بیشترین مقدار قیمت

تابع ووکامرسی wc_get_min_max_price_meta_query – دریافت کمترین و بیشترین مقدار قیمت در کوئری
Syntax – سینتکس
(array) wc_get_min_max_price_meta_query( (array) $args );
Parameters – پارامتر ها (1)
- 1- $args (array)
Usage – نحوه استفاده
if ( !function_exists( 'wc_get_min_max_price_meta_query' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-product-functions.php';
}
// Min price and max price arguments.
$args = array();
// NOTICE! Understand what this does before running.
$result = wc_get_min_max_price_meta_query($args);
Defined – محل تعریف
/includes/wc-product-functions.php
function wc_get_min_max_price_meta_query( $args ) {
$min = isset( $args['min_price'] ) ? floatval( $args['min_price'] ) : 0;
$max = isset( $args['max_price'] ) ? floatval( $args['max_price'] ) : 9999999999;
/**
* Adjust if the store taxes are not displayed how they are stored.
* Max is left alone because the filter was already increased.
* Kicks in when prices excluding tax are displayed including tax.
*/
if ( wc_tax_enabled() && 'incl' === get_option( 'woocommerce_tax_display_shop' ) && ! wc_prices_include_tax() ) {
$tax_classes = array_merge( array( '' ), WC_Tax::get_tax_classes() );
$class_min = $min;
foreach ( $tax_classes as $tax_class ) {
if ( $tax_rates = WC_Tax::get_rates( $tax_class ) ) {
$class_min = $min - WC_Tax::get_tax_total( WC_Tax::calc_exclusive_tax( $min, $tax_rates ) );
}
}
$min = $class_min;
}
return array(
'key' => '_price',
'value' => array( $min, $max ),
'compare' => 'BETWEEN',
'type' => 'NUMERIC',
);
}
versions – نسخه ها
از نسخه : 3.0.0
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر