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


PHP WC_Subscriptions_Manager::get_all_users_subscriptions方法代码示例

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


在下文中一共展示了WC_Subscriptions_Manager::get_all_users_subscriptions方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
     $this->get_column_info();
     $this->process_actions();
     if (isset($_REQUEST['s'])) {
         $subscriptions_grouped_by_user = WC_Subscriptions_Manager::search_subscriptions($_REQUEST['s']);
     } elseif (isset($_GET['_customer_user']) || isset($_GET['_product_id'])) {
         if (isset($_GET['_customer_user']) && !empty($_GET['_customer_user'])) {
             $subscriptions_grouped_by_user = array($_GET['_customer_user'] => WC_Subscriptions_Manager::get_users_subscriptions($_GET['_customer_user']));
         } else {
             $subscriptions_grouped_by_user = WC_Subscriptions_Manager::get_all_users_subscriptions();
         }
         if (isset($_GET['_product_id']) && !empty($_GET['_product_id'])) {
             foreach ($subscriptions_grouped_by_user as $user_id => $subscriptions) {
                 foreach ($subscriptions as $subscription_key => $subscription) {
                     if ($subscription['product_id'] == intval($_GET['_product_id'])) {
                         continue;
                     }
                     $order_item = WC_Subscriptions_Order::get_item_by_product_id($subscription['order_id'], $subscription['product_id']);
                     if (isset($order_item['variation_id']) && $order_item['variation_id'] == intval($_GET['_product_id'])) {
                         continue;
                     }
                     unset($subscriptions_grouped_by_user[$user_id][$subscription_key]);
                 }
             }
         }
     } else {
         $subscriptions_grouped_by_user = WC_Subscriptions_Manager::get_all_users_subscriptions();
     }
     $status_to_show = isset($_GET['status']) ? $_GET['status'] : 'all';
     // Reformat the subscriptions grouped by user to be usable by each row
     $subscriptions = array();
     $this->statuses = array();
     foreach ($subscriptions_grouped_by_user as $user_id => $users_subscriptions) {
         foreach ($users_subscriptions as $subscription_key => $subscription) {
             $this->statuses[$subscription['status']] = isset($this->statuses[$subscription['status']]) ? $this->statuses[$subscription['status']] + 1 : 1;
             $all_subscriptions[$subscription_key] = $subscription + array('user_id' => $user_id, 'subscription_key' => $subscription_key);
             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($this->statuses[$status_to_show])) {
         if ($status_to_show != 'all') {
             $status_to_show = $_GET['status'] = 'all';
             foreach ($all_subscriptions as $subscription_key => $subscription) {
                 if ($all_subscriptions[$subscription_key]['status'] != 'trash') {
                     $subscriptions = $subscriptions + array($subscription_key => $subscription);
                 }
             }
         } else {
             $_GET['status'] = 'all';
         }
     }
     ksort($this->statuses);
     $this->statuses = array('all' => array_sum($this->statuses)) + $this->statuses;
     if (isset($this->statuses['trash'])) {
         $this->statuses['all'] = $this->statuses['all'] - $this->statuses['trash'];
     }
     usort($subscriptions, array(&$this, 'sort_subscriptions'));
     // Add sorted & sliced data to the items property to be used by the rest of the class
     $this->items = array_slice($subscriptions, ($this->get_pagenum() - 1) * $per_page, $per_page);
     $total_items = count($subscriptions);
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
 }
开发者ID:bulats,项目名称:chef,代码行数:79,代码来源:class-wc-subscriptions-list-table.php

示例2: woo_ce_return_count


//.........这里部分代码省略.........
								} else {
									$order->email = '-';
								}
							}
							if( !in_array( $order->email, $customers ) ) {
								$customers[$order->ID] = $order->email;
								$count++;
							}
						}
						unset( $orders, $order );
					}
				}
*/
				break;

			case 'user':
				if( $users = count_users() )
					$count = $users['total_users'];
				break;

			case 'coupon':
				$post_type = 'shop_coupon';
				if( post_type_exists( $post_type ) )
					$count = wp_count_posts( $post_type );
				break;

			case 'subscription':
				$count = 0;
				// Check that WooCommerce Subscriptions exists
				if( class_exists( 'WC_Subscriptions' ) ) {
					if( method_exists( 'WC_Subscriptions', 'is_large_site' ) ) {
						// Does this store have roughly more than 3000 Subscriptions
						if( false === WC_Subscriptions::is_large_site() ) {
							if( class_exists( 'WC_Subscriptions_Manager' ) ) {
								// Check that the get_all_users_subscriptions() function exists
								if( method_exists( 'WC_Subscriptions_Manager', 'get_all_users_subscriptions' ) ) {
									if( $subscriptions = WC_Subscriptions_Manager::get_all_users_subscriptions() ) {
										foreach( $subscriptions as $key => $user_subscription ) {
											if( !empty( $user_subscription ) ) {
												foreach( $user_subscription as $subscription )
													$count++;
											}
										}
										unset( $subscriptions, $subscription, $user_subscription );
									}
								}
							}
						} else {
							if( method_exists( 'WC_Subscriptions', 'get_total_subscription_count' ) )
								$count = WC_Subscriptions::get_total_subscription_count();
							else
								$count = "~2500";
						}
					}
				}
				break;

			case 'product_vendor':
				$term_taxonomy = 'shop_vendor';
				if( taxonomy_exists( $term_taxonomy ) )
					$count = wp_count_terms( $term_taxonomy );
				break;

			case 'commission':
				$post_type = 'shop_commission';
				if( post_type_exists( $post_type ) )
					$count = wp_count_posts( $post_type );
				break;

			case 'shipping_class':
				$term_taxonomy = 'product_shipping_class';
				if( taxonomy_exists( $term_taxonomy ) )
					$count = wp_count_terms( $term_taxonomy );
				break;

			case 'attribute':
				$attributes = ( function_exists( 'wc_get_attribute_taxonomies' ) ? wc_get_attribute_taxonomies() : array() );
				$count = count( $attributes );
				break;

		}
		if( isset( $count ) || $count_sql ) {
			if( isset( $count ) ) {
				if( is_object( $count ) ) {
					$count = (array)$count;
					$count = (int)array_sum( $count );
				}
				return $count;
			} else {
				if( $count_sql )
					$count = $wpdb->get_var( $count_sql );
				else
					$count = 0;
			}
			return $count;
		} else {
			return 0;
		}

	}
开发者ID:helloworld-digital,项目名称:katemorgan,代码行数:101,代码来源:functions.php

示例3: 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

示例4: add_subscribers_to_customers

 /**
  * Add users with subscriptions to the "Customers" report in WooCommerce -> Reports.
  *
  * @param WP_User_Query $user_query
  */
 public static function add_subscribers_to_customers($user_query)
 {
     global $plugin_page, $wpdb;
     /** @var wpdb $wpdb */
     //Check if the current query is the "Total Customers" query
     //from the WooCommerce -> Reports -> Customers tab.
     $current_tab = isset($_GET['tab']) ? sanitize_title(urldecode($_GET['tab'])) : 'sales';
     $is_customer_query = is_admin() && $plugin_page === 'woocommerce_reports' && $current_tab === 'customers' && isset($user_query->query_vars['role']) && $user_query->query_vars['role'] === 'customer';
     if ($is_customer_query) {
         $users_with_subscriptions = WC_Subscriptions_Manager::get_all_users_subscriptions();
         $include_user_ids = array();
         foreach ($users_with_subscriptions as $user_id => $subscriptions) {
             if (!empty($subscriptions)) {
                 $include_user_ids[] = $user_id;
             }
         }
         if (!empty($include_user_ids)) {
             //Turn the original customer query into a sub-query.
             $user_query->query_from = "FROM {$wpdb->users} LEFT JOIN (\n\t\t\t\t\t\tSELECT {$wpdb->users}.ID\n\t\t\t\t\t\t{$user_query->query_from}\n\t\t\t\t\t\t{$user_query->query_where}\n\t\t\t\t\t) AS customers ON (customers.ID = {$wpdb->users}.ID)";
             //Select users with subscriptions + customers returned by the original query.
             $user_query->query_where = sprintf("WHERE ({$wpdb->users}.ID IN (%s)) OR (customers.ID IS NOT NULL)", implode(', ', $include_user_ids));
         }
     }
 }
开发者ID:bulats,项目名称:chef,代码行数:29,代码来源:class-wc-subscriptions-admin.php

示例5: get_orders_for_email

 /**
  * Get orders that match the $email's criteria
  * @param array     $orders Matching Order IDs
  * @param FUE_Email $email
  * @return array
  */
 public function get_orders_for_email($orders, $email)
 {
     $wpdb = Follow_Up_Emails::instance()->wpdb;
     $all_subscriptions = WC_Subscriptions_Manager::get_all_users_subscriptions();
     $status_array = array('subs_activated' => 'active', 'subs_cancelled' => 'cancelled', 'subs_expired' => 'expired', 'subs_suspended' => 'suspended');
     $status_triggers = array_keys($status_array);
     if (in_array($email->trigger, $status_triggers)) {
         $status = $status_array[$email->trigger];
         foreach ($all_subscriptions as $user_id => $subscriptions) {
             foreach ($subscriptions as $subscription) {
                 if ($subscription['status'] != $status) {
                     continue;
                 }
                 $in_queue = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*)\n                        FROM {$wpdb->prefix}followup_email_orders\n                        WHERE order_id = %d\n                        AND email_id = %d", $subscription['order_id'], $email->id));
                 if ($in_queue) {
                     continue;
                 }
                 $orders[] = $subscription['order_id'];
             }
         }
     } elseif ($email->trigger == 'subs_renewed') {
         // get orders with active subscriptions AND renewals
         foreach ($all_subscriptions as $user_id => $subscriptions) {
             foreach ($subscriptions as $subscription) {
                 if ($subscription['status'] == 'active' && count($subscription['completed_payments']) >= 2) {
                     $in_queue = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*)\n                        FROM {$wpdb->prefix}followup_email_orders\n                        WHERE order_id = %d\n                        AND email_id = %d", $subscription['order_id'], $email->id));
                     if ($in_queue) {
                         continue;
                     }
                     $orders[] = $subscription['order_id'];
                 }
             }
         }
     } elseif ($email->trigger == 'subs_reactivated') {
         // get active subscriptions with at least 1 suspension count
         foreach ($all_subscriptions as $user_id => $subscriptions) {
             foreach ($subscriptions as $subscription) {
                 if ($subscription['status'] == 'active' && absint($subscription['suspension_count']) > 0) {
                     $in_queue = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*)\n                            FROM {$wpdb->prefix}followup_email_orders\n                            WHERE order_id = %d\n                            AND email_id = %d", $subscription['order_id'], $email->id));
                     if ($in_queue) {
                         continue;
                     }
                     $orders[] = $subscription['order_id'];
                 }
             }
         }
     } elseif ($email->trigger == 'subs_renewal_order') {
         $order_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_parent > 0 AND post_type = 'shop_order' ORDER BY {$wpdb->posts}.post_date ASC");
         foreach ($order_ids as $order_id) {
             $in_queue = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*)\n                    FROM {$wpdb->prefix}followup_email_orders\n                    WHERE order_id = %d\n                    AND email_id = %d", $order_id, $email->id));
             if ($in_queue) {
                 continue;
             }
             $orders[] = $order_id;
         }
     } elseif ($email->trigger == 'subs_before_renewal' || $email->trigger == 'subs_before_expire') {
         foreach ($all_subscriptions as $user_id => $subscriptions) {
             foreach ($subscriptions as $subscription) {
                 if ($subscription['status'] != 'active') {
                     continue;
                 }
                 $in_queue = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*)\n                        FROM {$wpdb->prefix}followup_email_orders\n                        WHERE order_id = %d\n                        AND email_id = %d", $subscription['order_id'], $email->id));
                 if ($in_queue) {
                     continue;
                 }
                 $orders[] = $subscription['order_id'];
             }
         }
     }
     return $orders;
 }
开发者ID:bself,项目名称:nuimage-wp,代码行数:77,代码来源:class-fue-addon-subscriptions.php

示例6: add_subscribers_to_customers

 /**
  * Add users with subscriptions to the "Customers" report in WooCommerce -> Reports.
  *
  * @param WP_User_Query $user_query
  */
 public static function add_subscribers_to_customers($user_query)
 {
     global $plugin_page, $wpdb;
     if (!is_admin() || $plugin_page !== 'woocommerce_reports' || !isset($_GET['tab'])) {
         return $user_query;
     }
     if ('customers' === $_GET['tab'] && isset($user_query->query_vars['role']) && $user_query->query_vars['role'] === 'customer') {
         $users_with_subscriptions = WC_Subscriptions_Manager::get_all_users_subscriptions();
         $include_user_ids = array();
         foreach ($users_with_subscriptions as $user_id => $subscriptions) {
             if (!empty($subscriptions)) {
                 $include_user_ids[] = $user_id;
             }
         }
         if (!empty($include_user_ids)) {
             //Turn the original customer query into a sub-query.
             $user_query->query_from = "FROM {$wpdb->users} LEFT JOIN (\n\t\t\t\t\t\tSELECT {$wpdb->users}.ID\n\t\t\t\t\t\t{$user_query->query_from}\n\t\t\t\t\t\t{$user_query->query_where}\n\t\t\t\t\t) AS customers ON (customers.ID = {$wpdb->users}.ID)";
             //Select users with subscriptions + customers returned by the original query.
             $user_query->query_where = sprintf("WHERE ({$wpdb->users}.ID IN (%s)) OR (customers.ID IS NOT NULL)", implode(', ', $include_user_ids));
         }
     }
 }
开发者ID:keshvenderg,项目名称:cloudshop,代码行数:27,代码来源:class-wc-subscriptions-admin.php

示例7: send_manual_email

 public function send_manual_email($recipients, $post)
 {
     global $wpdb;
     if ($post['send_type'] == 'active_subscription') {
         $subscriptions = WC_Subscriptions_Manager::get_all_users_subscriptions();
         foreach ($subscriptions as $user_id => $user_subscriptions) {
             foreach ($user_subscriptions as $sub_key => $subscription) {
                 if ($subscription['product_id'] == $post['subscription_id'] || $subscription['variation_id'] == $post['subscription_id']) {
                     $user = new WP_User($user_id);
                     $key = $user->user_id . '|' . $user->user_email . '|' . $user->first_name . ' ' . $user->last_name;
                     $recipients[$key] = array($user->user_id, $user->user_email, $user->first_name . ' ' . $user->last_name);
                 }
             }
         }
     }
     return $recipients;
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:17,代码来源:class.fue_subscriptions.php

示例8: 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()
 {
     $per_page = 10;
     $this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns());
     $this->process_actions();
     $subscriptions_grouped_by_user = WC_Subscriptions_Manager::get_all_users_subscriptions();
     $status_to_show = isset($_GET['status']) ? $_GET['status'] : 'all';
     // Reformat the subscriptions grouped by user to be usable by each row
     $subscriptions = array();
     $this->statuses = array();
     foreach ($subscriptions_grouped_by_user as $user_id => $users_subscriptions) {
         foreach ($users_subscriptions as $subscription_key => $subscription) {
             $this->statuses[$subscription['status']] = isset($this->statuses[$subscription['status']]) ? $this->statuses[$subscription['status']] + 1 : 1;
             $all_subscriptions[$subscription_key] = $subscription + array('user_id' => $user_id, 'subscription_key' => $subscription_key);
             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($this->statuses[$status_to_show])) {
         if ($status_to_show != 'all') {
             $status_to_show = $_GET['status'] = 'all';
             foreach ($all_subscriptions as $subscription_key => $subscription) {
                 if ($all_subscriptions[$subscription_key]['status'] != 'trash') {
                     $subscriptions = $subscriptions + array($subscription_key => $subscription);
                 }
             }
         } else {
             $_GET['status'] = 'all';
         }
     }
     ksort($this->statuses);
     $this->statuses = array('all' => array_sum($this->statuses)) + $this->statuses;
     if (isset($this->statuses['trash'])) {
         $this->statuses['all'] = $this->statuses['all'] - $this->statuses['trash'];
     }
     usort($subscriptions, array(&$this, 'sort_subscriptions'));
     // Add sorted & sliced data to the items property to be used by the rest of the class
     $this->items = array_slice($subscriptions, ($this->get_pagenum() - 1) * $per_page, $per_page);
     $total_items = count($subscriptions);
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
 }
开发者ID:picassentviu,项目名称:AMMPro,代码行数:54,代码来源:class-wc-subscriptions-list-table.php

示例9: generate_renewal_orders

 /**
  * Version 1.2 introduced child renewal orders to keep a record of each completed subscription
  * payment. Before 1.2, these orders did not exist, so this function creates them.
  *
  * @since 1.2
  */
 private static function generate_renewal_orders()
 {
     global $woocommerce, $wpdb;
     $subscriptions_grouped_by_user = WC_Subscriptions_Manager::get_all_users_subscriptions();
     // Don't send any order emails
     $email_actions = array('woocommerce_low_stock', 'woocommerce_no_stock', 'woocommerce_product_on_backorder', 'woocommerce_order_status_pending_to_processing', 'woocommerce_order_status_pending_to_completed', 'woocommerce_order_status_pending_to_on-hold', 'woocommerce_order_status_failed_to_processing', 'woocommerce_order_status_failed_to_completed', 'woocommerce_order_status_pending_to_processing', 'woocommerce_order_status_pending_to_on-hold', 'woocommerce_order_status_completed', 'woocommerce_new_customer_note');
     foreach ($email_actions as $action) {
         remove_action($action, array(&$woocommerce, 'send_transactional_email'));
     }
     remove_action('woocommerce_payment_complete', 'WC_Subscriptions_Renewal_Order::maybe_record_renewal_order_payment', 10, 1);
     foreach ($subscriptions_grouped_by_user as $user_id => $users_subscriptions) {
         foreach ($users_subscriptions as $subscription_key => $subscription) {
             $order_post = get_post($subscription['order_id']);
             if (isset($subscription['completed_payments']) && count($subscription['completed_payments']) > 0 && $order_post != null) {
                 foreach ($subscription['completed_payments'] as $payment_date) {
                     $existing_renewal_order = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_date_gmt = %s AND post_parent = %d AND post_type = 'shop_order'", $payment_date, $subscription['order_id']));
                     // If a renewal order exists on this date, don't generate another one
                     if (NULL !== $existing_renewal_order) {
                         continue;
                     }
                     $renewal_order_id = WC_Subscriptions_Renewal_Order::generate_renewal_order($subscription['order_id'], $subscription['product_id'], array('new_order_role' => 'child'));
                     if ($renewal_order_id) {
                         // Mark the order as paid
                         $renewal_order = new WC_Order($renewal_order_id);
                         $renewal_order->payment_complete();
                         // Avoid creating 100s "processing" orders
                         $renewal_order->update_status('completed');
                         // Set correct dates on the order
                         $renewal_order = array('ID' => $renewal_order_id, 'post_date' => $payment_date, 'post_date_gmt' => $payment_date);
                         wp_update_post($renewal_order);
                         update_post_meta($renewal_order_id, '_paid_date', $payment_date);
                         update_post_meta($renewal_order_id, '_completed_date', $payment_date);
                     }
                 }
             }
         }
     }
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:44,代码来源:class-wc-subscriptions-upgrader.php


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