تابع ووکامرسی wc_orders_count نمایش تعداد کل سفارشات با توجه به وضعیت

تابع ووکامرسی wc_orders_count – نمایش تعداد کل سفارشات با توجه به وضعیت
Syntax – سینتکس
(int) wc_orders_count( (string) $status );
Parameters – پارامتر ها (1)
- 1- $status (string)
Usage – نحوه استفاده
if ( !function_exists( 'wc_orders_count' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-order-functions.php';
}
// The status.
$status = '';
// NOTICE! Understand what this does before running.
$result = wc_orders_count($status);
Defined – محل تعریف
/includes/wc-order-functions.php
function wc_orders_count( $status ) {
$count = 0;
$status = 'wc-' . $status;
$order_statuses = array_keys( wc_get_order_statuses() );
if ( ! in_array( $status, $order_statuses ) ) {
return 0;
}
$cache_key = WC_Cache_Helper::get_cache_prefix( 'orders' ) . $status;
$cached_count = wp_cache_get( $cache_key, 'counts' );
if ( false !== $cached_count ) {
return $cached_count;
}
foreach ( wc_get_order_types( 'order-count' ) as $type ) {
$data_store = WC_Data_Store::load( 'shop_order' === $type ? 'order' : $type );
if ( $data_store ) {
$count += $data_store->get_order_count( $status );
}
}
wp_cache_set( $cache_key, $count, 'counts' );
return $count;
}
versions – نسخه ها
از نسخه : 3.0.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر