当前位置: 首页>>代码示例>>PHP>>正文


PHP WC_Subscriptions::get_subscription_count方法代码示例

本文整理汇总了PHP中WC_Subscriptions::get_subscription_count方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Subscriptions::get_subscription_count方法的具体用法?PHP WC_Subscriptions::get_subscription_count怎么用?PHP WC_Subscriptions::get_subscription_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Subscriptions的用法示例。


在下文中一共展示了WC_Subscriptions::get_subscription_count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepare_items

 /**
  * Get, sort and filter subscriptions for display.
  *
  * @uses $this->_column_headers
  * @uses $this->items
  * @uses $this->get_columns()
  * @uses $this->get_sortable_columns()
  * @uses $this->get_pagenum()
  * @uses $this->set_pagination_args()
  * @since 1.0
  */
 function prepare_items()
 {
     $screen = get_current_screen();
     $per_page = $this->get_items_per_page($screen->get_option('per_page', 'option'), 10);
     $paged = isset($_GET['paged']) ? $_GET['paged'] : 1;
     $this->get_column_info();
     $this->process_actions();
     $status_to_show = isset($_GET['status']) ? $_GET['status'] : 'all';
     $subscriptions_query = array('paged' => $paged, 'subscriptions_per_page' => $per_page, 'subscription_status' => $status_to_show, 'order' => !empty($_REQUEST['order']) ? strtoupper($_REQUEST['order']) : 'DESC', 'orderby' => !empty($_REQUEST['orderby']) ? $_REQUEST['orderby'] : '_subscription_start_date');
     // Filter by a certain customer?
     if (isset($_GET['_customer_user']) && !empty($_GET['_customer_user'])) {
         $subscriptions_query['customer_id'] = $_GET['_customer_user'];
     }
     // Filter by a certain product?
     if (isset($_GET['_product_id']) && !empty($_GET['_product_id'])) {
         $subscriptions_query['product_id'] = $_GET['_product_id'];
     }
     $subscriptions = WC_Subscriptions::get_subscriptions($subscriptions_query);
     $total_items = WC_Subscriptions::get_subscription_count($subscriptions_query);
     $this->statuses = array();
     foreach ($subscriptions as $subscription) {
         $this->statuses[$subscription['status']] = isset($this->statuses[$subscription['status']]) ? $this->statuses[$subscription['status']] + 1 : 1;
     }
     $this->statuses = WC_Subscriptions::get_subscription_status_counts();
     if (isset($this->statuses['trash'])) {
         $this->statuses['all'] = $this->statuses['all'] - $this->statuses['trash'];
     }
     // Add sorted & sliced data to the items property to be used by the rest of the class
     $this->items = $subscriptions;
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
 }
开发者ID:bulats,项目名称:chef,代码行数:42,代码来源:class-wc-subscriptions-list-table.php

示例2: prepare_items

 /**
  * Get, sort and filter subscriptions for display.
  *
  * @uses $this->_column_headers
  * @uses $this->items
  * @uses $this->get_columns()
  * @uses $this->get_sortable_columns()
  * @uses $this->get_pagenum()
  * @uses $this->set_pagination_args()
  * @since 1.0
  */
 function prepare_items()
 {
     global $wcs_list_table_statuses;
     $screen = get_current_screen();
     $per_page = $this->get_items_per_page($screen->get_option('per_page', 'option'), 10);
     $paged = isset($_GET['paged']) ? $_GET['paged'] : 1;
     $this->get_column_info();
     $status_to_show = isset($_GET['status']) ? $_GET['status'] : 'all';
     if (isset($_REQUEST['s']) || !empty($_REQUEST['orderby']) && 'next_payment_date' === $_REQUEST['orderby']) {
         @set_time_limit(300);
         $subscriptions = $wcs_list_table_statuses = array();
         // It's a search
         if (isset($_REQUEST['s'])) {
             $subscriptions_grouped_by_user = WC_Subscriptions_Manager::search_subscriptions($_REQUEST['s']);
         } else {
             // Order by next payment date
             $subscriptions_grouped_by_user = WC_Subscriptions_Manager::get_all_users_subscriptions();
         }
         foreach ($subscriptions_grouped_by_user as $user_id => $users_subscriptions) {
             // Filter by a certain customer?
             if (isset($_GET['_customer_user']) && (int) $user_id !== (int) $_GET['_customer_user']) {
                 continue;
             }
             foreach ($users_subscriptions as $subscription_key => $subscription) {
                 // Filter by a certain product?
                 if (isset($_GET['_product_id']) && (int) $subscription['product_id'] !== (int) $_GET['_product_id']) {
                     continue;
                 }
                 $wcs_list_table_statuses[$subscription['status']] = isset($wcs_list_table_statuses[$subscription['status']]) ? $wcs_list_table_statuses[$subscription['status']] + 1 : 1;
                 if ($status_to_show == $subscription['status'] || $status_to_show == 'all' && $subscription['status'] != 'trash') {
                     $subscriptions[$subscription_key] = $subscription + array('user_id' => $user_id, 'subscription_key' => $subscription_key);
                 }
             }
         }
         // If we have a request for a status that does not exist, default to all subscriptions
         if (!isset($wcs_list_table_statuses[$status_to_show])) {
             if ($status_to_show != 'all') {
                 $status_to_show = $_GET['status'] = 'all';
                 foreach ($subscriptions_grouped_by_user as $user_id => $users_subscriptions) {
                     // Filter by a certain customer?
                     if (isset($_GET['_customer_user']) && (int) $user_id !== (int) $_GET['_customer_user']) {
                         continue;
                     }
                     foreach ($users_subscriptions as $subscription_key => $subscription) {
                         // Filter by a certain product?
                         if (isset($_GET['_product_id']) && (int) $subscription['product_id'] !== (int) $_GET['_product_id']) {
                             continue;
                         }
                         $subscriptions[$subscription_key] = $subscription + array('user_id' => $user_id, 'subscription_key' => $subscription_key);
                     }
                 }
             } else {
                 $_GET['status'] = 'all';
             }
         }
         ksort($wcs_list_table_statuses);
         $wcs_list_table_statuses = array('all' => array_sum($wcs_list_table_statuses)) + $wcs_list_table_statuses;
         if (isset($wcs_list_table_statuses['trash'])) {
             $wcs_list_table_statuses['all'] = $wcs_list_table_statuses['all'] - $wcs_list_table_statuses['trash'];
         }
         $total_items = count($subscriptions);
         @usort($subscriptions, array(&$this, 'sort_subscriptions'));
         // Need to suppress warnings due to PHP bug here: https://bugs.php.net/bug.php?id=50688
         $subscriptions = array_slice($subscriptions, ($paged - 1) * $per_page, $per_page);
     } else {
         $subscriptions_query = array('paged' => $paged, 'subscriptions_per_page' => $per_page, 'subscription_status' => $status_to_show, 'order' => !empty($_REQUEST['order']) ? strtoupper($_REQUEST['order']) : 'DESC', 'orderby' => !empty($_REQUEST['orderby']) ? $_REQUEST['orderby'] : '_subscription_start_date');
         // Filter by a certain customer?
         if (isset($_GET['_customer_user']) && !empty($_GET['_customer_user'])) {
             $subscriptions_query['customer_id'] = $_GET['_customer_user'];
         }
         // Filter by a certain product?
         if (isset($_GET['_product_id']) && !empty($_GET['_product_id'])) {
             $subscriptions_query['product_id'] = $_GET['_product_id'];
         }
         $subscriptions = WC_Subscriptions::get_subscriptions($subscriptions_query);
         $wcs_list_table_statuses = WC_Subscriptions::get_subscription_status_counts();
         if (isset($wcs_list_table_statuses['trash'])) {
             $wcs_list_table_statuses['all'] = $wcs_list_table_statuses['all'] - $wcs_list_table_statuses['trash'];
         }
         if ('all' === $status_to_show && !isset($subscriptions_query['customer_id']) && !isset($subscriptions_query['product_id'])) {
             $total_items = $wcs_list_table_statuses['all'];
         } else {
             $total_items = WC_Subscriptions::get_subscription_count($subscriptions_query);
         }
     }
     // Add sorted & sliced data to the items property to be used by the rest of the class
     $this->items = $subscriptions;
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
 }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:100,代码来源:class-wc-subscriptions-list-table.php

示例3: wc_subs_exporter_get_subscription_statuses

<?php

if (isset($_POST['from_date'])) {
    $from_date = $_POST['from_date'];
} else {
    $from_date = '';
}
if (isset($_POST['to_date'])) {
    $to_date = $_POST['to_date'];
} else {
    $to_date = '';
}
// initialize subscription status count
$subscription_statuses = wc_subs_exporter_get_subscription_statuses();
foreach ($subscription_statuses as $key => $status) {
    $subscription_count[$key] = WC_Subscriptions::get_subscription_count(array('subscription_status' => $key));
}
?>
<p>
  <?php 
_e('Make a selection below to export entries.', 'wc-subs-exporter');
?>
<br />
  <?php 
_e('When you click the export button below, Subscription Exporter will create a CSV file for you to save to your computer.', 'wc-subs-exporter');
?>
</p>
<form method="post" action="<?php 
echo add_query_arg(array('failed' => null, 'empty' => null));
?>
" id="postform">
开发者ID:arobbins,项目名称:spellestate,代码行数:31,代码来源:wc-subs-exporter-admin_export.php


注:本文中的WC_Subscriptions::get_subscription_count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。