本文整理汇总了PHP中wc_get_order_types函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_get_order_types函数的具体用法?PHP wc_get_order_types怎么用?PHP wc_get_order_types使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_get_order_types函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: query_report_data
/**
* Get all data needed for this report and store in the class
*/
private function query_report_data()
{
$this->report_data = new stdClass();
$this->report_data->orders = (array) $this->get_order_report_data(array('data' => array('_order_total' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_sales'), '_order_shipping' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_shipping'), '_order_tax' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_tax'), '_order_shipping_tax' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_shipping_tax'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => array_merge(array('shop_order_refund'), wc_get_order_types('sales-reports')), 'order_status' => array('completed', 'processing', 'on-hold'), 'parent_order_status' => array('completed', 'processing', 'on-hold')));
$this->report_data->order_counts = (array) $this->get_order_report_data(array('data' => array('ID' => array('type' => 'post_data', 'function' => 'COUNT', 'name' => 'count', 'distinct' => true), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => wc_get_order_types('order-count'), 'order_status' => array('completed', 'processing', 'on-hold')));
$this->report_data->coupons = (array) $this->get_order_report_data(array('data' => array('order_item_name' => array('type' => 'order_item', 'function' => '', 'name' => 'order_item_name'), 'discount_amount' => array('type' => 'order_item_meta', 'order_item_type' => 'coupon', 'function' => 'SUM', 'name' => 'discount_amount'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'where' => array(array('key' => 'order_items.order_item_type', 'value' => 'coupon', 'operator' => '=')), 'group_by' => $this->group_by_query . ', order_item_name', 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => wc_get_order_types('order-count'), 'order_status' => array('completed', 'processing', 'on-hold')));
$this->report_data->order_items = (array) $this->get_order_report_data(array('data' => array('_qty' => array('type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'order_item_count'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'where' => array(array('key' => 'order_items.order_item_type', 'value' => 'line_item', 'operator' => '=')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => wc_get_order_types('order-count'), 'order_status' => array('completed', 'processing', 'on-hold')));
$this->report_data->refunded_order_items = (array) $this->get_order_report_data(array('data' => array('_qty' => array('type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'order_item_count'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'where' => array(array('key' => 'order_items.order_item_type', 'value' => 'line_item', 'operator' => '=')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => wc_get_order_types('order-count'), 'order_status' => array('refunded')));
$this->report_data->partial_refunds = (array) $this->get_order_report_data(array('data' => array('_refund_amount' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_refund'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date'), '_qty' => array('type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'order_item_count')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_status' => false, 'parent_order_status' => array('completed', 'processing', 'on-hold')));
foreach ($this->report_data->partial_refunds as $key => $value) {
$this->report_data->partial_refunds[$key]->order_item_count = $this->report_data->partial_refunds[$key]->order_item_count * -1;
}
$this->report_data->order_items = array_merge($this->report_data->order_items, $this->report_data->partial_refunds);
$this->report_data->total_order_refunds = array_sum((array) absint($this->get_order_report_data(array('data' => array('ID' => array('type' => 'post_data', 'function' => 'COUNT', 'name' => 'total_orders')), 'query_type' => 'get_var', 'filter_range' => true, 'order_types' => wc_get_order_types('order-count'), 'order_status' => array('refunded')))));
$this->report_data->full_refunds = (array) $this->get_order_report_data(array('data' => array('_order_total' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_refund'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_status' => array('refunded')));
$this->report_data->refunds = array_merge($this->report_data->partial_refunds, $this->report_data->full_refunds);
$this->report_data->total_sales = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->orders, 'total_sales')), 2);
$this->report_data->total_tax = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->orders, 'total_tax')), 2);
$this->report_data->total_shipping = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->orders, 'total_shipping')), 2);
$this->report_data->total_shipping_tax = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->orders, 'total_shipping_tax')), 2);
$this->report_data->total_refunds = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->partial_refunds, 'total_refund')) + array_sum(wp_list_pluck($this->report_data->full_refunds, 'total_refund')), 2);
$this->report_data->total_coupons = number_format(array_sum(wp_list_pluck($this->report_data->coupons, 'discount_amount')), 2);
$this->report_data->total_orders = absint(array_sum(wp_list_pluck($this->report_data->order_counts, 'count')));
$this->report_data->total_partial_refunds = array_sum(wp_list_pluck($this->report_data->partial_refunds, 'order_item_count')) * -1;
$this->report_data->total_item_refunds = array_sum(wp_list_pluck($this->report_data->refunded_order_items, 'order_item_count')) * -1;
$this->report_data->total_items = absint(array_sum(wp_list_pluck($this->report_data->order_items, 'order_item_count')) * -1);
$this->report_data->average_sales = wc_format_decimal($this->report_data->total_sales / ($this->chart_interval + 1), 2);
$this->report_data->net_sales = wc_format_decimal($this->report_data->total_sales - $this->report_data->total_shipping - $this->report_data->total_tax - $this->report_data->total_shipping_tax, 2);
}
开发者ID:amusiiko,项目名称:armo,代码行数:32,代码来源:class-wc-report-sales-by-date.php
示例2: get_chart_legend
/**
* Get the legend for the main chart sidebar
* @return array
*/
public function get_chart_legend()
{
$legend = array();
$order_totals = $this->get_order_report_data(array('data' => array('_order_total' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_sales'), '_order_shipping' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_shipping')), 'filter_range' => true));
$total_sales = $order_totals->total_sales;
$total_shipping = $order_totals->total_shipping;
$total_orders = absint($this->get_order_report_data(array('data' => array('ID' => array('type' => 'post_data', 'function' => 'COUNT', 'name' => 'total_orders')), 'query_type' => 'get_var', 'filter_range' => true, 'order_types' => wc_get_order_types('order-count'))));
$total_items = absint($this->get_order_report_data(array('data' => array('_qty' => array('type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'order_item_qty')), 'query_type' => 'get_var', 'order_types' => wc_get_order_types('order-count'), 'filter_range' => true)));
// Get discount amounts in range
$total_coupons = $this->get_order_report_data(array('data' => array('discount_amount' => array('type' => 'order_item_meta', 'order_item_type' => 'coupon', 'function' => 'SUM', 'name' => 'discount_amount')), 'where' => array(array('key' => 'order_items.order_item_type', 'value' => 'coupon', 'operator' => '=')), 'query_type' => 'get_var', 'order_types' => wc_get_order_types('order-count'), 'filter_range' => true));
$this->average_sales = $total_sales / ($this->chart_interval + 1);
switch ($this->chart_groupby) {
case 'day':
$average_sales_title = sprintf(__('%s average daily sales', 'woocommerce'), '<strong>' . wc_price($this->average_sales) . '</strong>');
break;
case 'month':
$average_sales_title = sprintf(__('%s average monthly sales', 'woocommerce'), '<strong>' . wc_price($this->average_sales) . '</strong>');
break;
}
$legend[] = array('title' => sprintf(__('%s sales in this period', 'woocommerce'), '<strong>' . wc_price($total_sales) . '</strong>'), 'color' => $this->chart_colours['sales_amount'], 'highlight_series' => 5);
$legend[] = array('title' => $average_sales_title, 'color' => $this->chart_colours['average'], 'highlight_series' => 2);
$legend[] = array('title' => sprintf(__('%s orders placed', 'woocommerce'), '<strong>' . $total_orders . '</strong>'), 'color' => $this->chart_colours['order_count'], 'highlight_series' => 1);
$legend[] = array('title' => sprintf(__('%s items purchased', 'woocommerce'), '<strong>' . $total_items . '</strong>'), 'color' => $this->chart_colours['item_count'], 'highlight_series' => 0);
$legend[] = array('title' => sprintf(__('%s charged for shipping', 'woocommerce'), '<strong>' . wc_price($total_shipping) . '</strong>'), 'color' => $this->chart_colours['shipping_amount'], 'highlight_series' => 4);
$legend[] = array('title' => sprintf(__('%s worth of coupons used', 'woocommerce'), '<strong>' . wc_price($total_coupons) . '</strong>'), 'color' => $this->chart_colours['coupon_amount'], 'highlight_series' => 3);
return $legend;
}
开发者ID:anagio,项目名称:woocommerce,代码行数:31,代码来源:class-wc-report-sales-by-date.php
示例3: update_ransaction_status
public function update_ransaction_status()
{
global $wpdb;
$held_duration = get_option('woocommerce_hold_stock_minutes');
if ($held_duration < 1 || get_option('woocommerce_manage_stock') != 'yes') {
return;
}
$date = date("Y-m-d H:i:s", strtotime('-' . absint(0) . ' MINUTES', current_time('timestamp')));
$unpaid_orders = $wpdb->get_results($wpdb->prepare("\n\t\t\tSELECT posts.ID, postmeta.meta_key, postmeta.meta_value, posts.post_modified\n\t\t\tFROM {$wpdb->posts} AS posts\n\t\t\tRIGHT JOIN {$wpdb->postmeta} AS postmeta ON posts.id=postmeta.post_id\n\t\t\tWHERE \tposts.post_type IN ('" . implode("','", wc_get_order_types()) . "')\n\t\t\tAND \tposts.post_status = 'wc-pending'\n\t\t\tAND \tposts.post_modified + INTERVAL 10 MINUTE < %s\n\t\t", $date));
$pending_array = '';
foreach ($unpaid_orders as $value) {
if ($value->meta_key == '_order_total') {
$pending_array[] = $value;
}
}
if (!empty($pending_array)) {
$response_URL = "https://paynetzuat.atomtech.in/paynetz/vfts";
$this->atom_port = $this->settings['atom_port'];
foreach ($pending_array as $val) {
$mer_txn = $val->ID;
$amt = $val->meta_value;
$date = date("Y-m-d", strtotime($val->post_modified));
$merchant_id = 160;
$param = "?merchantid=" . $merchant_id . "&merchanttxnid=" . $mer_txn . "&amt=" . $amt . "&tdate=" . $date;
$ch = curl_init();
$useragent = 'woo-commerce plugin';
curl_setopt($ch, CURLOPT_URL, $response_URL);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_PORT, 443);
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//information received from gateway is stored in $response.
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo '<div class="woocommerce-error">Curl error: "' . curl_error($ch) . ". Error in gateway credentials.</div>";
die;
}
curl_close($ch);
$parser = xml_parser_create('');
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, trim($response), $xml_values);
xml_parser_free($parser);
$result_resp = $xml_values[0]['attributes']['VERIFIED'];
$unpaid_order = $mer_txn;
if ($unpaid_order) {
$order = wc_get_order($unpaid_order);
if (apply_filters('woocommerce_cancel_unpaid_order', 'checkout' === get_post_meta($unpaid_order, '_created_via', true), $order)) {
if ($result_resp == 'SUCCESS') {
$order->update_status('completed', __('Unpaid order completed - time limit reached.', 'woocommerce'));
}
}
}
}
}
}
开发者ID:atomtechnologyltd,项目名称:Wordpress_4.3.1_Woocommerce_2.3.4,代码行数:59,代码来源:woocommerce-atom-gateway.php
示例4: wc_get_screen_ids
/**
* Get all WooCommerce screen ids
*
* @return array
*/
function wc_get_screen_ids()
{
$wc_screen_id = sanitize_title(__('WooCommerce', 'woocommerce'));
$screen_ids = array('toplevel_page_' . $wc_screen_id, $wc_screen_id . '_page_wc-reports', $wc_screen_id . '_page_wc-settings', $wc_screen_id . '_page_wc-status', $wc_screen_id . '_page_wc-addons', 'toplevel_page_wc-reports', 'product_page_product_attributes', 'edit-product', 'product', 'edit-shop_coupon', 'shop_coupon', 'edit-product_cat', 'edit-product_tag', 'edit-product_shipping_class', 'profile', 'user-edit');
foreach (wc_get_order_types() as $type) {
$screen_ids[] = $type;
$screen_ids[] = 'edit-' . $type;
}
return apply_filters('woocommerce_screen_ids', $screen_ids);
}
开发者ID:abesamislyndon,项目名称:femaccms,代码行数:15,代码来源:wc-admin-functions.php
示例5: restrict_manage_posts
/**
* Filters for post types
*/
public function restrict_manage_posts()
{
global $typenow, $wp_query;
if (in_array($typenow, wc_get_order_types('order-meta-boxes'))) {
$selected_coutry = isset($_GET['country']) ? $_GET['country'] : 'all';
$countries = array_merge(array('all' => __('All countries', 'woocommerce-jetpack')), wcj_get_countries());
echo '<select id="country" name="country">';
foreach ($countries as $code => $name) {
echo '<option value="' . $code . '" ' . selected($code, $selected_coutry, false) . '>' . $name . '</option>';
}
echo '</select>';
}
}
开发者ID:yarwalker,项目名称:ecobyt,代码行数:16,代码来源:class-wcj-orders.php
示例6: woocommerce_dashboard_status_widget_sales_query
public function woocommerce_dashboard_status_widget_sales_query($query)
{
global $wpdb;
// Replace query to one that returns the totals in base currency
$query = array();
$query['fields'] = "SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts";
$query['join'] = "INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id ";
$query['where'] = "WHERE posts.post_type IN ( '" . implode("','", wc_get_order_types('reports')) . "' ) ";
$query['where'] .= "AND posts.post_status IN ( 'wc-" . implode("','wc-", apply_filters('woocommerce_reports_order_statuses', array('completed', 'processing', 'on-hold'))) . "' ) ";
$query['where'] .= "AND postmeta.meta_key = '_order_total_base_currency' ";
$query['where'] .= "AND posts.post_date >= '" . date('Y-m-01', current_time('timestamp')) . "' ";
$query['where'] .= "AND posts.post_date <= '" . date('Y-m-d H:i:s', current_time('timestamp')) . "' ";
return $query;
}
开发者ID:keshvenderg,项目名称:cloudshop,代码行数:14,代码来源:wc-aelia-reports-wc22.php
示例7: column_default
/**
* column_default function.
*
* @param WP_User $user
* @param string $column_name
* @return string
*/
public function column_default($user, $column_name)
{
global $wpdb;
if ('orders' == $column_name) {
if (!($count = get_user_meta($user->ID, '_order_count', true))) {
global $wpdb;
$count = $wpdb->get_var("SELECT COUNT(*)\r\n\t\t\t\t\tFROM {$wpdb->posts} as posts\r\n\r\n\t\t\t\t\tLEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id\r\n\r\n\t\t\t\t\tWHERE meta.meta_key = '_customer_user'\r\n\t\t\t\t\tAND posts.post_type IN ('" . implode("','", wc_get_order_types('order-count')) . "')\r\n\t\t\t\t\tAND posts.post_status IN ('" . implode("','", array_keys(wc_get_order_statuses())) . "')\r\n\t\t\t\t\tAND posts.post_parent = 0\r\n\t\t\t\t\tAND meta_value = {$user->ID}\r\n\t\t\t\t");
update_user_meta($user->ID, '_order_count', absint($count));
}
$result = absint($count);
} else {
$result = parent::column_default($user, $column_name);
}
return $result;
}
开发者ID:shwetadubey,项目名称:upfit,代码行数:22,代码来源:class.yith-report-customer-list.php
示例8: exclude_comments
public static function exclude_comments($clauses)
{
global $wpdb, $typenow;
if (is_admin() && in_array($typenow, wc_get_order_types()) && current_user_can('manage_woocommerce')) {
return $clauses;
// Don't hide when viewing orders in admin
}
if (!$clauses['join']) {
$clauses['join'] = '';
}
if (!strstr($clauses['join'], "JOIN {$wpdb->posts}")) {
$clauses['join'] .= " LEFT JOIN {$wpdb->posts} ON comment_post_ID = {$wpdb->posts}.ID ";
}
if ($clauses['where']) {
$clauses['where'] .= ' AND ';
}
$clauses['where'] .= " {$wpdb->posts}.post_type NOT IN ('" . implode("','", wc_crm_get_exclude_comments_post_types()) . "') ";
return $clauses;
}
开发者ID:sajidshah,项目名称:le-dolci,代码行数:19,代码来源:wc_crm_post-types.php
示例9: query_report_data
/**
* Get all data needed for this report and store in the class
*/
private function query_report_data()
{
$this->report_data = new stdClass();
$this->report_data->orders = (array) $this->get_order_report_data(array('data' => array('_order_total' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_sales'), '_order_shipping' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_shipping'), '_order_tax' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_tax'), '_order_shipping_tax' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_shipping_tax'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => wc_get_order_types('sales-reports'), 'order_status' => array('completed', 'processing', 'on-hold', 'refunded')));
$this->report_data->refunded_orders = (array) $this->get_order_report_data(array('data' => array('_order_total' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_sales'), '_order_shipping' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_shipping'), '_order_tax' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_tax'), '_order_shipping_tax' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_shipping_tax'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date'), 'ID' => array('type' => 'post_data', 'function' => 'COUNT', 'name' => 'count', 'distinct' => true)), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => wc_get_order_types('sales-reports'), 'order_status' => array('refunded')));
$this->report_data->order_counts = (array) $this->get_order_report_data(array('data' => array('ID' => array('type' => 'post_data', 'function' => 'COUNT', 'name' => 'count', 'distinct' => true), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => wc_get_order_types('order-count'), 'order_status' => array('completed', 'processing', 'on-hold', 'refunded')));
$this->report_data->coupons = (array) $this->get_order_report_data(array('data' => array('order_item_name' => array('type' => 'order_item', 'function' => '', 'name' => 'order_item_name'), 'discount_amount' => array('type' => 'order_item_meta', 'order_item_type' => 'coupon', 'function' => 'SUM', 'name' => 'discount_amount'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'where' => array(array('key' => 'order_items.order_item_type', 'value' => 'coupon', 'operator' => '=')), 'group_by' => $this->group_by_query . ', order_item_name', 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => wc_get_order_types('order-count'), 'order_status' => array('completed', 'processing', 'on-hold', 'refunded')));
$this->report_data->refunds = (array) $this->get_order_report_data(array('data' => array('_refund_amount' => array('type' => 'meta', 'function' => '', 'name' => 'total_refund'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date'), '_qty' => array('type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'order_item_count', 'join_type' => 'LEFT')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_status' => false, 'parent_order_status' => array('completed', 'processing', 'on-hold', 'refunded')));
foreach ($this->report_data->refunds as $key => $value) {
$this->report_data->refunds[$key]->order_item_count = $this->report_data->refunds[$key]->order_item_count * -1;
}
// All items from orders - even those refunded
$this->report_data->order_items = (array) $this->get_order_report_data(array('data' => array('_qty' => array('type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'order_item_count'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'where' => array(array('key' => 'order_items.order_item_type', 'value' => 'line_item', 'operator' => '=')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => wc_get_order_types('order-count'), 'order_status' => array('completed', 'processing', 'on-hold', 'refunded')));
// All items from FULLY refunded orders for the time period
$this->report_data->refunded_order_items = (array) $this->get_order_report_data(array('data' => array('_qty' => array('type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'order_item_count', 'join_type' => 'LEFT'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'where' => array(array('key' => 'order_items.order_item_type', 'value' => 'line_item', 'operator' => '=')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => wc_get_order_types('order-count'), 'order_status' => array('refunded')));
// All partially refunded items
$this->report_data->partially_refunded_order_items = (array) $this->get_order_report_data(array('data' => array('post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date'), '_qty' => array('type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'order_item_count')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_status' => false, 'parent_order_status' => array('completed', 'processing', 'on-hold')));
// Combine partial and full refund item quantities
$this->report_data->refunded_order_items = array_merge($this->report_data->refunded_order_items, $this->report_data->partially_refunded_order_items);
// Totals from only refunded orders
$this->report_data->total_tax_refunded = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->refunded_orders, 'total_tax')), 2);
$this->report_data->total_shipping_refunded = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->refunded_orders, 'total_shipping')), 2);
$this->report_data->total_shipping_tax_refunded = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->refunded_orders, 'total_shipping_tax')), 2);
// Totals from all orders - including those refunded. Subtract refunded amounts.
$this->report_data->total_tax = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->orders, 'total_tax')) - $this->report_data->total_tax_refunded, 2);
$this->report_data->total_shipping = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->orders, 'total_shipping')) - $this->report_data->total_shipping_refunded, 2);
$this->report_data->total_shipping_tax = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->orders, 'total_shipping_tax')) - $this->report_data->total_shipping_tax_refunded, 2);
// Total the refunds and sales amounts. Sales subract refunds.
$this->report_data->total_refunds = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->refunds, 'total_refund')), 2);
$this->report_data->total_sales = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->orders, 'total_sales')) - $this->report_data->total_refunds, 2);
$this->report_data->net_sales = wc_format_decimal($this->report_data->total_sales - $this->report_data->total_shipping - $this->report_data->total_tax - $this->report_data->total_shipping_tax, 2);
// Calculate average based on net
$this->report_data->average_sales = wc_format_decimal($this->report_data->net_sales / ($this->chart_interval + 1), 2);
// Total orders and discounts also includes those which have been refunded at some point
$this->report_data->total_orders = absint(array_sum(wp_list_pluck($this->report_data->order_counts, 'count')));
$this->report_data->total_coupons = number_format(array_sum(wp_list_pluck($this->report_data->coupons, 'discount_amount')), 2);
$this->report_data->total_refunded_orders = absint(array_sum(wp_list_pluck($this->report_data->refunded_orders, 'count')));
// Item counts
$this->report_data->total_item_refunds = array_sum(wp_list_pluck($this->report_data->refunded_order_items, 'order_item_count'));
$this->report_data->total_items = absint(array_sum(wp_list_pluck($this->report_data->order_items, 'order_item_count')));
}
开发者ID:nightbook,项目名称:woocommerce,代码行数:44,代码来源:class-wc-report-sales-by-date.php
示例10: status_widget
/**
* Show status widget
*/
public function status_widget()
{
global $wpdb;
include_once 'reports/class-wc-admin-report.php';
$reports = new WC_Admin_Report();
// Sales
$query = array();
$query['fields'] = "SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts";
$query['join'] = "INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id LEFT JOIN {$wpdb->posts} AS parent ON posts.post_parent = parent.ID";
$query['where'] = "WHERE posts.post_type IN ( '" . implode("','", array_merge(wc_get_order_types('sales-reports'), array('shop_order_refund'))) . "' ) ";
$query['where'] .= "AND posts.post_status IN ( 'wc-" . implode("','wc-", apply_filters('woocommerce_reports_order_statuses', array('completed', 'processing', 'on-hold'))) . "' ) ";
$query['where'] .= "AND ( parent.post_status IN ( 'wc-" . implode("','wc-", apply_filters('woocommerce_reports_order_statuses', array('completed', 'processing', 'on-hold'))) . "' ) OR parent.ID IS NULL ) ";
$query['where'] .= "AND postmeta.meta_key = '_order_total' ";
$query['where'] .= "AND posts.post_date >= '" . date('Y-m-01', current_time('timestamp')) . "' ";
$query['where'] .= "AND posts.post_date <= '" . date('Y-m-d H:i:s', current_time('timestamp')) . "' ";
$sales = $wpdb->get_var(implode(' ', apply_filters('woocommerce_dashboard_status_widget_sales_query', $query)));
// Get top seller
$query = array();
$query['fields'] = "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id\n\t\t\tFROM {$wpdb->posts} as posts";
$query['join'] = "INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_id ";
$query['join'] .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id ";
$query['join'] .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_2 ON order_items.order_item_id = order_item_meta_2.order_item_id ";
$query['where'] = "WHERE posts.post_type IN ( '" . implode("','", wc_get_order_types('order-count')) . "' ) ";
$query['where'] .= "AND posts.post_status IN ( 'wc-" . implode("','wc-", apply_filters('woocommerce_reports_order_statuses', array('completed', 'processing', 'on-hold'))) . "' ) ";
$query['where'] .= "AND order_item_meta.meta_key = '_qty' ";
$query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' ";
$query['where'] .= "AND posts.post_date >= '" . date('Y-m-01', current_time('timestamp')) . "' ";
$query['where'] .= "AND posts.post_date <= '" . date('Y-m-d H:i:s', current_time('timestamp')) . "' ";
$query['groupby'] = "GROUP BY product_id";
$query['orderby'] = "ORDER BY qty DESC";
$query['limits'] = "LIMIT 1";
$top_seller = $wpdb->get_row(implode(' ', apply_filters('woocommerce_dashboard_status_widget_top_seller_query', $query)));
// Counts
$on_hold_count = 0;
$processing_count = 0;
foreach (wc_get_order_types('order-count') as $type) {
$counts = (array) wp_count_posts($type);
$on_hold_count += isset($counts['wc-on-hold']) ? $counts['wc-on-hold'] : 0;
$processing_count += isset($counts['wc-processing']) ? $counts['wc-processing'] : 0;
}
// Get products using a query - this is too advanced for get_posts :(
$stock = absint(max(get_option('woocommerce_notify_low_stock_amount'), 1));
$nostock = absint(max(get_option('woocommerce_notify_no_stock_amount'), 0));
$transient_name = 'wc_low_stock_count';
if (false === ($lowinstock_count = get_transient($transient_name))) {
$query_from = apply_filters('woocommerce_report_low_in_stock_query_from', "FROM {$wpdb->posts} as posts\n\t\t\t\tINNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id\n\t\t\t\tINNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id\n\t\t\t\tWHERE 1=1\n\t\t\t\tAND posts.post_type IN ( 'product', 'product_variation' )\n\t\t\t\tAND posts.post_status = 'publish'\n\t\t\t\tAND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes'\n\t\t\t\tAND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$stock}'\n\t\t\t\tAND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) > '{$nostock}'\n\t\t\t");
$lowinstock_count = absint($wpdb->get_var("SELECT COUNT( DISTINCT posts.ID ) {$query_from};"));
set_transient($transient_name, $lowinstock_count, DAY_IN_SECONDS * 30);
}
$transient_name = 'wc_outofstock_count';
if (false === ($outofstock_count = get_transient($transient_name))) {
$query_from = apply_filters('woocommerce_report_out_of_stock_query_from', "FROM {$wpdb->posts} as posts\n\t\t\t\tINNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id\n\t\t\t\tINNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id\n\t\t\t\tWHERE 1=1\n\t\t\t\tAND posts.post_type IN ( 'product', 'product_variation' )\n\t\t\t\tAND posts.post_status = 'publish'\n\t\t\t\tAND postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes'\n\t\t\t\tAND postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$nostock}'\n\t\t\t");
$outofstock_count = absint($wpdb->get_var("SELECT COUNT( DISTINCT posts.ID ) {$query_from};"));
set_transient($transient_name, $outofstock_count, DAY_IN_SECONDS * 30);
}
?>
<ul class="wc_status_list">
<li class="sales-this-month">
<a href="<?php
echo admin_url('admin.php?page=wc-reports&tab=orders&range=month');
?>
">
<?php
echo $reports->sales_sparkline('', max(7, date('d', current_time('timestamp'))));
?>
<?php
printf(__("<strong>%s</strong> sales this month", 'woocommerce'), wc_price($sales));
?>
</a>
</li>
<?php
if ($top_seller && $top_seller->qty) {
?>
<li class="best-seller-this-month">
<a href="<?php
echo admin_url('admin.php?page=wc-reports&tab=orders&report=sales_by_product&range=month&product_ids=' . $top_seller->product_id);
?>
">
<?php
echo $reports->sales_sparkline($top_seller->product_id, max(7, date('d', current_time('timestamp'))), 'count');
?>
<?php
printf(__("%s top seller this month (sold %d)", 'woocommerce'), "<strong>" . get_the_title($top_seller->product_id) . "</strong>", $top_seller->qty);
?>
</a>
</li>
<?php
}
?>
<li class="processing-orders">
<a href="<?php
echo admin_url('edit.php?post_status=wc-processing&post_type=shop_order');
?>
">
<?php
printf(_n("<strong>%s order</strong> awaiting processing", "<strong>%s orders</strong> awaiting processing", $processing_count, 'woocommerce'), $processing_count);
?>
//.........这里部分代码省略.........
开发者ID:CannedHead,项目名称:feelingsurf,代码行数:101,代码来源:class-wc-admin-dashboard.php
示例11: wc_get_customer_order_count
/**
* Get total orders by customer.
* @param int $user_id
* @return int
*/
function wc_get_customer_order_count($user_id)
{
if (!($count = get_user_meta($user_id, '_order_count', true))) {
global $wpdb;
$count = $wpdb->get_var("SELECT COUNT(*)\n\t\t\tFROM {$wpdb->posts} as posts\n\n\t\t\tLEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id\n\n\t\t\tWHERE meta.meta_key = '_customer_user'\n\t\t\tAND posts.post_type IN ('" . implode("','", wc_get_order_types('order-count')) . "')\n\t\t\tAND posts.post_status IN ('" . implode("','", array_keys(wc_get_order_statuses())) . "')\n\t\t\tAND meta_value = {$user_id}\n\t\t");
update_user_meta($user_id, '_order_count', absint($count));
}
return absint($count);
}
开发者ID:robbenz,项目名称:plugs,代码行数:14,代码来源:wc-user-functions.php
示例12: wc_processing_order_count
/**
* Return the count of processing orders.
*
* @access public
* @return int
*/
function wc_processing_order_count()
{
$count = 0;
foreach (wc_get_order_types('order-count') as $type) {
$this_count = wp_count_posts($type, 'readable');
$count += isset($this_count->{'wc-processing'}) ? $this_count->{'wc-processing'} : 0;
}
return $count;
}
开发者ID:amusiiko,项目名称:armo,代码行数:15,代码来源:wc-order-functions.php
示例13: should_deliver
/**
* Helper to check if the webhook should be delivered, as some hooks
* (like `wp_trash_post`) will fire for every post type, not just ours.
*
* @since 2.2
* @param mixed $arg first hook argument
* @return bool true if webhook should be delivered, false otherwise
*/
private function should_deliver($arg)
{
// only active webhooks can be delivered
if ('active' != $this->get_status()) {
return false;
}
$current_action = current_action();
// only deliver deleted event for coupons, orders, and products
if ('delete_post' == $current_action && !in_array($GLOBALS['post_type'], array('shop_coupon', 'shop_order', 'product'))) {
return false;
} elseif ('delete_user' == $current_action) {
$user = get_userdata(absint($arg));
// only deliver deleted customer event for users with customer role
if (!$user || !in_array('customer', (array) $user->roles)) {
return false;
}
// check if the custom order type has chosen to exclude order webhooks from triggering along with its own webhooks.
} elseif ('order' == $this->get_resource() && !in_array(get_post_type(absint($arg)), wc_get_order_types('order-webhooks'))) {
return false;
} elseif (0 === strpos($current_action, 'woocommerce_process_shop')) {
// the `woocommerce_process_shop_*` hook fires for both updates
// and creation so check the post creation date to determine the actual event
$resource = get_post(absint($arg));
// a resource is considered created when the hook is executed within 10 seconds of the post creation date
$resource_created = time() - 10 <= strtotime($resource->post_date_gmt);
if ('created' == $this->get_event() && !$resource_created) {
return false;
} elseif ('updated' == $this->get_event() && $resource_created) {
return false;
}
}
return true;
}
开发者ID:nightbook,项目名称:woocommerce,代码行数:41,代码来源:class-wc-webhook.php
示例14: avada_woocommerce_before_my_account
function avada_woocommerce_before_my_account($order_count, $edit_address = false)
{
global $woocommerce;
$edit_address = is_wc_endpoint_url('edit-address');
avada_top_user_container();
?>
<ul class="woocommerce-side-nav avada-myaccount-nav">
<?php
if ($downloads = WC()->customer->get_downloadable_products()) {
?>
<li <?php
if (!$edit_address) {
echo 'class="active"';
}
?>
>
<a class="downloads" href="#">
<?php
_e('View Downloads', 'Avada');
?>
</a>
</li>
<?php
}
if (function_exists('wc_get_order_types') && function_exists('wc_get_order_statuses')) {
$customer_orders = get_posts(apply_filters('woocommerce_my_account_my_orders_query', array('numberposts' => $order_count, 'meta_key' => '_customer_user', 'meta_value' => get_current_user_id(), 'post_type' => wc_get_order_types('view-orders'), 'post_status' => array_keys(wc_get_order_statuses()))));
} else {
$customer_orders = get_posts(apply_filters('woocommerce_my_account_my_orders_query', array('numberposts' => $order_count, 'meta_key' => '_customer_user', 'meta_value' => get_current_user_id(), 'post_type' => 'shop_order', 'post_status' => 'publish')));
}
if ($customer_orders) {
?>
<li <?php
if (!$edit_address && !WC()->customer->get_downloadable_products()) {
echo 'class="active"';
}
?>
>
<a class="orders" href="#">
<?php
_e('View Orders', 'Avada');
?>
</a>
</li>
<?php
}
?>
<li <?php
if ($edit_address || !WC()->customer->get_downloadable_products() && !$customer_orders) {
echo 'class="active"';
}
?>
>
<a class="address" href="#">
<?php
_e('Change Address', 'Avada');
?>
</a>
</li>
<li>
<a class="account" href="#">
<?php
_e('Edit Account', 'Avada');
?>
</a>
</li>
</ul>
<div class="woocommerce-content-box avada-myaccount-data">
<?php
}
开发者ID:Aldebaran10,项目名称:avada,代码行数:72,代码来源:woo-config.php
|
请发表评论