array(
array(
'title' => __('Overview', 'woothemes'),
'description' => '',
'hide_title' => true,
'function' => 'woocommerce_sales_overview'
),
array(
'title' => __('Daily Sales', 'woothemes'),
'description' => '',
'function' => 'woocommerce_daily_sales'
),
array(
'title' => __('Monthly Sales', 'woothemes'),
'description' => '',
'function' => 'woocommerce_monthly_sales'
),
array(
'title' => __('Product Sales', 'woothemes'),
'description' => '',
'function' => 'woocommerce_product_sales'
),
array(
'title' => __('Top sellers', 'woothemes'),
'description' => '',
'function' => 'woocommerce_top_sellers'
),
array(
'title' => __('Top earners', 'woothemes'),
'description' => '',
'function' => 'woocommerce_top_earners'
)
),
__('customers', 'woothemes') => array(
array(
'title' => __('Overview', 'woothemes'),
'description' => '',
'hide_title' => true,
'function' => 'woocommerce_customer_overview'
),
),
__('stock', 'woothemes') => array(
array(
'title' => __('Overview', 'woothemes'),
'description' => '',
'hide_title' => true,
'function' => 'woocommerce_stock_overview'
),
)
);
?>
1) : ?>
- $chart) :
$link = ''.$chart['title'].'';
$links[] = $link;
endforeach;
echo implode(' |
- ', $links);
?>
function weekendAreas(axes) {
var markings = [];
var d = new Date(axes.xaxis.min);
// go to the first Saturday
d.setUTCDate(d.getUTCDate() - ((d.getUTCDay() + 1) % 7))
d.setUTCSeconds(0);
d.setUTCMinutes(0);
d.setUTCHours(0);
var i = d.getTime();
do {
markings.push({ xaxis: { from: i, to: i + 2 * 24 * 60 * 60 * 1000 } });
i += 7 * 24 * 60 * 60 * 1000;
} while (i < axes.xaxis.max);
return markings;
}
function showTooltip(x, y, contents) {
jQuery('' + contents + '
').css( {
position: 'absolute',
display: 'none',
top: y + 5,
left: x + 5,
padding: '5px 10px',
border: '3px solid #3da5d5',
background: '#288ab7'
}).appendTo("body").fadeIn(200);
}
var previousPoint = null;
jQuery("#placeholder").bind("plothover", function (event, pos, item) {
if (item) {
if (previousPoint != item.dataIndex) {
previousPoint = item.dataIndex;
jQuery("#tooltip").remove();
if (item.series.label=="Sales amount") {
var y = item.datapoint[1].toFixed(2);
showTooltip(item.pageX, item.pageY, item.series.label + " - " + "" + y);
} else if (item.series.label=="Number of sales") {
var y = item.datapoint[1];
showTooltip(item.pageX, item.pageY, item.series.label + " - " + y);
} else {
var y = item.datapoint[1];
showTooltip(item.pageX, item.pageY, y);
}
}
}
else {
jQuery("#tooltip").remove();
previousPoint = null;
}
});
var dates = jQuery( "#from, #to" ).datepicker({
defaultDate: "",
dateFormat: "yy-mm-dd",
//changeMonth: true,
//changeYear: true,
numberOfMonths: 1,
minDate: "-12M",
maxDate: "+0D",
showButtonPanel: true,
showOn: "button",
buttonImage: "plugin_url(); ?>/assets/images/calendar.png",
buttonImageOnly: true,
onSelect: function( selectedDate ) {
var option = this.id == "from" ? "minDate" : "maxDate",
instance = jQuery( this ).data( "datepicker" ),
date = jQuery.datepicker.parseDate(
instance.settings.dateFormat ||
jQuery.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
'$after'";
$where .= " AND post_date < '$before'";
return $where;
}
/**
* Sales overview
*/
function woocommerce_sales_overview() {
global $start_date, $end_date, $woocommerce, $wpdb;
$total_sales = 0;
$total_orders = 0;
$order_items = 0;
$args = array(
'numberposts' => -1,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'shop_order',
'post_status' => 'publish' ,
'tax_query' => array(
array(
'taxonomy' => 'shop_order_status',
'terms' => array('completed', 'processing', 'on-hold'),
'field' => 'slug',
'operator' => 'IN'
)
)
);
$orders = get_posts( $args );
foreach ($orders as $order) :
$order_items_array = (array) get_post_meta($order->ID, '_order_items', true);
foreach ($order_items_array as $item) $order_items += (int) $item['qty'];
$total_sales += get_post_meta($order->ID, '_order_total', true);
$total_orders++;
endforeach;
?>
-1,
'orderby' => 'post_date',
'order' => 'ASC',
'post_type' => 'shop_order',
'post_status' => 'publish' ,
'suppress_filters'=> 0,
'tax_query' => array(
array(
'taxonomy' => 'shop_order_status',
'terms' => array('completed', 'processing', 'on-hold'),
'field' => 'slug',
'operator' => 'IN'
)
)
);
$orders = get_posts( $args );
$order_counts = array();
$order_amounts = array();
// Blank date ranges to begin
$count = 0;
$days = ($end_date - $start_date) / (60 * 60 * 24);
while ($count < $days) :
$time = strtotime(date('Ymd', strtotime('+ '.$count.' DAY', $start_date))).'000';
$order_counts[$time] = 0;
$order_amounts[$time] = 0;
$count++;
endwhile;
if ($orders) :
foreach ($orders as $order) :
$order_total = get_post_meta($order->ID, '_order_total', true);
$time = strtotime(date('Ymd', strtotime($order->post_date))).'000';
if (isset($order_counts[$time])) :
$order_counts[$time]++;
else :
$order_counts[$time] = 1;
endif;
if (isset($order_amounts[$time])) :
$order_amounts[$time] = $order_amounts[$time] + $order_total;
else :
$order_amounts[$time] = (float) $order_total;
endif;
endforeach;
endif;
remove_filter( 'posts_where', 'orders_within_range' );
$order_counts_array = array();
foreach ($order_counts as $key => $count) :
$order_counts_array[] = array($key, $count);
endforeach;
$order_amounts_array = array();
foreach ($order_amounts as $key => $amount) :
$order_amounts_array[] = array($key, $amount);
endforeach;
$order_data = array( 'order_counts' => $order_counts_array, 'order_amounts' => $order_amounts_array );
$chart_data = json_encode($order_data);
?>
-1,
'orderby' => 'post_date',
'order' => 'ASC',
'post_type' => 'shop_order',
'post_status' => 'publish' ,
'suppress_filters'=> 0,
'tax_query' => array(
array(
'taxonomy' => 'shop_order_status',
'terms' => array('completed', 'processing', 'on-hold'),
'field' => 'slug',
'operator' => 'IN'
)
)
);
$orders = get_posts( $args );
$order_counts = array();
$order_amounts = array();
// Blank date ranges to begin
$count = 0;
$days = ($end_date - $start_date) / (60 * 60 * 24);
while ($count < $days) :
$time = strtotime(date('Ymd', strtotime('+ '.$count.' DAY', $start_date))).'000';
$order_counts[$time] = 0;
$order_amounts[$time] = 0;
$count++;
endwhile;
if ($orders) :
foreach ($orders as $order) :
$order_total = get_post_meta($order->ID, '_order_total', true);
$time = strtotime(date('Ymd', strtotime($order->post_date))).'000';
$order_items_array = (array) get_post_meta($order->ID, '_order_items', true);
foreach ($order_items_array as $item) $order_items += (int) $item['qty'];
$total_sales += $order_total;
$total_orders++;
if (isset($order_counts[$time])) :
$order_counts[$time]++;
else :
$order_counts[$time] = 1;
endif;
if (isset($order_amounts[$time])) :
$order_amounts[$time] = $order_amounts[$time] + $order_total;
else :
$order_amounts[$time] = (float) $order_total;
endif;
endforeach;
endif;
remove_filter( 'posts_where', 'orders_within_range' );
?>
$count) :
$order_counts_array[] = array($key, $count);
endforeach;
$order_amounts_array = array();
foreach ($order_amounts as $key => $amount) :
$order_amounts_array[] = array($key, $amount);
endforeach;
$order_data = array( 'order_counts' => $order_counts_array, 'order_amounts' => $order_amounts_array );
$chart_data = json_encode($order_data);
?>
get_var("SELECT post_date FROM $wpdb->posts ORDER BY post_date ASC LIMIT 1;");
if ($first_year) $first_year = date('Y', strtotime($first_year)); else $first_year = date('Y');
$current_year = (isset($_POST['show_year'])) ? $_POST['show_year'] : date('Y');
$start_date = (isset($_POST['start_date'])) ? $_POST['start_date'] : '';
$end_date = (isset($_POST['end_date'])) ? $_POST['end_date'] : '';
if (!$start_date) $start_date = $current_year.'0101';
if (!$end_date) $end_date = date('Ym', current_time('timestamp')).'31';
$start_date = strtotime($start_date);
$end_date = strtotime($end_date);
$total_sales = 0;
$total_orders = 0;
$order_items = 0;
// Get orders to display in widget
add_filter( 'posts_where', 'orders_within_range' );
$args = array(
'numberposts' => -1,
'orderby' => 'post_date',
'order' => 'ASC',
'post_type' => 'shop_order',
'post_status' => 'publish' ,
'suppress_filters'=> 0,
'tax_query' => array(
array(
'taxonomy' => 'shop_order_status',
'terms' => array('completed', 'processing', 'on-hold'),
'field' => 'slug',
'operator' => 'IN'
)
)
);
$orders = get_posts( $args );
$order_counts = array();
$order_amounts = array();
// Blank date ranges to begin
$count = 0;
$months = ($end_date - $start_date) / (60 * 60 * 24 * 7 * 4);
while ($count < $months) :
$time = strtotime(date('Ym', strtotime('+ '.$count.' MONTH', $start_date)).'01').'000';
$order_counts[$time] = 0;
$order_amounts[$time] = 0;
$count++;
endwhile;
if ($orders) :
foreach ($orders as $order) :
$order_total = get_post_meta($order->ID, '_order_total', true);
$time = strtotime(date('Ym', strtotime($order->post_date)).'01').'000';
$order_items_array = (array) get_post_meta($order->ID, '_order_items', true);
foreach ($order_items_array as $item) $order_items += (int) $item['qty'];
$total_sales += $order_total;
$total_orders++;
if (isset($order_counts[$time])) :
$order_counts[$time]++;
else :
$order_counts[$time] = 1;
endif;
if (isset($order_amounts[$time])) :
$order_amounts[$time] = $order_amounts[$time] + $order_total;
else :
$order_amounts[$time] = (float) $order_total;
endif;
endforeach;
endif;
remove_filter( 'posts_where', 'orders_within_range' );
?>
$count) :
$order_counts_array[] = array($key, $count);
endforeach;
$order_amounts_array = array();
foreach ($order_amounts as $key => $amount) :
$order_amounts_array[] = array($key, $amount);
endforeach;
$order_data = array( 'order_counts' => $order_counts_array, 'order_amounts' => $order_amounts_array );
$chart_data = json_encode($order_data);
?>
-1,
'orderby' => 'post_date',
'order' => 'ASC',
'post_type' => 'shop_order',
'post_status' => 'publish' ,
'suppress_filters'=> 0,
'tax_query' => array(
array(
'taxonomy' => 'shop_order_status',
'terms' => array('completed', 'processing', 'on-hold'),
'field' => 'slug',
'operator' => 'IN'
)
)
);
$orders = get_posts( $args );
$found_products = array();
if ($orders) :
foreach ($orders as $order) :
$order_items = (array) get_post_meta( $order->ID, '_order_items', true );
foreach ($order_items as $item) :
$found_products[$item['id']] = isset($found_products[$item['id']]) ? $found_products[$item['id']] + $item['qty'] : $item['qty'];
endforeach;
endforeach;
endif;
asort($found_products);
$found_products = array_slice($found_products, 0, 25, true);
$found_products = array_reverse($found_products, true);
reset($found_products);
remove_filter( 'posts_where', 'orders_within_range' );
?>
|
|
$sales) :
$width = ($sales>0) ? ($sales / $max_sales) * 100 : 0;
$product = get_post($product_id);
if ($product) :
$product_name = ''.$product->post_title.'';
else :
$product_name = __('Product does not exist', 'woothemes');
endif;
echo ''.$product_name.' | '.$sales.' |
';
endforeach;
?>
-1,
'orderby' => 'post_date',
'order' => 'ASC',
'post_type' => 'shop_order',
'post_status' => 'publish' ,
'suppress_filters'=> 0,
'tax_query' => array(
array(
'taxonomy' => 'shop_order_status',
'terms' => array('completed', 'processing', 'on-hold'),
'field' => 'slug',
'operator' => 'IN'
)
)
);
$orders = get_posts( $args );
$found_products = array();
if ($orders) :
foreach ($orders as $order) :
$order_items = (array) get_post_meta( $order->ID, '_order_items', true );
foreach ($order_items as $item) :
$found_products[$item['id']] = isset($found_products[$item['id']]) ? $found_products[$item['id']] + ($item['qty'] + $item['cost']) : ($item['qty'] + $item['cost']);
endforeach;
endforeach;
endif;
asort($found_products);
$found_products = array_slice($found_products, 0, 25, true);
$found_products = array_reverse($found_products, true);
reset($found_products);
remove_filter( 'posts_where', 'orders_within_range' );
?>
|
|
$sales) :
$width = ($sales>0) ? (round($sales) / round($max_sales)) * 100 : 0;
$product = get_post($product_id);
if ($product) :
$product_name = ''.$product->post_title.'';
else :
$product_name = __('Product does not exist', 'woothemes');
endif;
echo ''.$product_name.' | '.woocommerce_price($sales).' |
';
endforeach;
?>
-1,
'orderby' => 'post_date',
'order' => 'ASC',
'post_type' => 'shop_order',
'post_status' => 'publish' ,
'suppress_filters'=> 0,
'tax_query' => array(
array(
'taxonomy' => 'shop_order_status',
'terms' => array('completed', 'processing', 'on-hold'),
'field' => 'slug',
'operator' => 'IN'
)
)
);
$orders = get_posts( $args );
$max_sales = 0;
$max_totals = 0;
$product_sales = array();
$product_totals = array();
if ($orders) :
foreach ($orders as $order) :
$date = date('Ym', strtotime( $order->post_date ));
$order_items = (array) get_post_meta( $order->ID, '_order_items', true );
foreach ($order_items as $item) :
if ($item['id']!=$chosen_product_id) continue;
$product_sales[$date] = isset($product_sales[$date]) ? $product_sales[$date] + $item['qty'] : $item['qty'];
$product_totals[$date] = isset($product_totals[$date]) ? $product_totals[$date] + ($item['qty'] * $item['cost']) : ($item['qty'] * $item['cost']);
if ($product_sales[$date] > $max_sales) $max_sales = $product_sales[$date];
if ($product_totals[$date] > $max_totals) $max_totals = $product_totals[$date];
endforeach;
endforeach;
endif;
remove_filter( 'posts_where', 'orders_within_range' );
endif;
?>
|
|
0) foreach ($product_sales as $date => $sales) :
$width = ($sales>0) ? (round($sales) / round($max_sales)) * 100 : 0;
$width2 = ($product_totals[$date]>0) ? (round($product_totals[$date]) / round($max_totals)) * 100 : 0;
echo ''.date('F', strtotime($date.'01')).' |
'.$sales.'
'.woocommerce_price($product_totals[$date]).'
|
';
endforeach; else echo ''.__('No sales :(', 'woothemes').' |
';
?>
array('user_registered'),
'role' => 'customer'
) );
$customers = $users_query->get_results();
$total_customers = (int) sizeof($customers);
$args = array(
'numberposts' => -1,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'shop_order',
'post_status' => 'publish' ,
'tax_query' => array(
array(
'taxonomy' => 'shop_order_status',
'terms' => array('completed', 'processing', 'on-hold'),
'field' => 'slug',
'operator' => 'IN'
)
)
);
$orders = get_posts( $args );
foreach ($orders as $order) :
if (get_post_meta( $order->ID, '_customer_user', true )>0) :
$total_customer_sales += get_post_meta($order->ID, '_order_total', true);
$total_customer_orders++;
else :
$total_guest_sales += get_post_meta($order->ID, '_order_total', true);
$total_guest_orders++;
endif;
endforeach;
?>
user_registered) > $start_date) :
$time = strtotime(date('Ymd', strtotime($customer->user_registered))).'000';
if (isset($signups[$time])) :
$signups[$time]++;
else :
$signups[$time] = 1;
endif;
endif;
endforeach;
$signups_array = array();
foreach ($signups as $key => $count) :
$signups_array[] = array($key, $count);
endforeach;
$chart_data = json_encode($signups_array);
?>
array('user_registered'),
'role' => 'customer'
) );
$customers = $users_query->get_results();
$total_customers = (int) sizeof($customers);
$args = array(
'numberposts' => -1,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'shop_order',
'post_status' => 'publish' ,
'tax_query' => array(
array(
'taxonomy' => 'shop_order_status',
'terms' => array('completed', 'processing', 'on-hold'),
'field' => 'slug',
'operator' => 'IN'
)
)
);
$orders = get_posts( $args );
foreach ($orders as $order) :
if (get_post_meta( $order->ID, '_customer_user', true )>0) :
$total_customer_sales += get_post_meta($order->ID, '_order_total', true);
$total_customer_orders++;
else :
$total_guest_sales += get_post_meta($order->ID, '_order_total', true);
$total_guest_orders++;
endif;
endforeach;
// Low/No stock lists
$lowstockamount = get_option('woocommerce_notify_low_stock_amount');
if (!is_numeric($lowstockamount)) $lowstockamount = 1;
$nostockamount = get_option('woocommerce_notify_no_stock_amount');
if (!is_numeric($nostockamount)) $nostockamount = 0;
$outofstock = array();
$lowinstock = array();
// Get low in stock simple/downloadable/virtual products. Grouped don't have stock. Variations need a separate query.
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'manage_stock',
'value' => 'yes'
),
array(
'key' => 'stock',
'value' => $lowstockamount,
'compare' => '<=',
'type' => 'NUMERIC'
)
),
'tax_query' => array(
array(
'taxonomy' => 'product_type',
'field' => 'slug',
'terms' => array('simple', 'downloadable', 'virtual'),
'operator' => 'IN'
)
)
);
$low_stock_products = (array) get_posts($args);
// Get low stock product variations
$args = array(
'post_type' => 'product_variation',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'stock',
'value' => $lowstockamount,
'compare' => '<=',
'type' => 'NUMERIC'
),
array(
'key' => 'stock',
'value' => array('', false, null),
'compare' => 'NOT IN'
)
)
);
$low_stock_variations = (array) get_posts($args);
// Finally, get low stock variable products (where stock is set for the parent)
$args = array(
'post_type' => array('product'),
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'manage_stock',
'value' => 'yes'
),
array(
'key' => 'stock',
'value' => $lowstockamount,
'compare' => '<=',
'type' => 'NUMERIC'
)
),
'tax_query' => array(
array(
'taxonomy' => 'product_type',
'field' => 'slug',
'terms' => array('variable'),
'operator' => 'IN'
)
)
);
$low_stock_variable_products = (array) get_posts($args);
// Merge results
$low_in_stock = array_merge($low_stock_products, $low_stock_variations, $low_stock_variable_products);
?>