Пример #1
0
/**
 * Sales overview factory function
 *
 * @since 1.0
 *
 * @global type $woocommerce
 * @global WPDB $wpdb
 * @global type $wp_locale
 * @global WP_User $current_user
 * @param type $start_date
 * @param type $end_date
 * @param type $heading
 */
function dokan_report_sales_overview($start_date, $end_date, $heading = '')
{
    global $woocommerce, $wpdb, $wp_locale, $current_user;
    $total_sales = $total_orders = $order_items = $discount_total = $shipping_total = 0;
    $order_totals = dokan_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'), 'ID' => array('type' => 'post_data', 'function' => 'COUNT', 'name' => 'total_orders')), 'filter_range' => true), $start_date, $end_date);
    $total_sales = $order_totals->total_sales;
    $total_shipping = $order_totals->total_shipping;
    $total_orders = absint($order_totals->total_orders);
    $total_items = absint(dokan_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', 'filter_range' => true), $start_date, $end_date));
    // Get discount amounts in range
    $total_coupons = dokan_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_item_type', 'value' => 'coupon', 'operator' => '=')), 'query_type' => 'get_var', 'filter_range' => true), $start_date, $end_date);
    $average_sales = $total_sales / (30 + 1);
    $legend = apply_filters('dokan-seller-dashboard-reports-left-sidebar', array('sales_in_this_period' => array('title' => sprintf(__('%s sales in this period', 'dokan'), '<strong>' . wc_price($total_sales) . '</strong>')), 'average_daily_sales' => array('title' => sprintf(__('%s average daily sales', 'dokan'), '<strong>' . wc_price($average_sales) . '</strong>')), 'orders_placed' => array('title' => sprintf(__('%s orders placed', 'dokan'), '<strong>' . $total_orders . '</strong>')), 'items_purchased' => array('title' => sprintf(__('%s items purchased', 'dokan'), '<strong>' . $total_items . '</strong>')), 'charged_for_shipping' => array('title' => sprintf(__('%s charged for shipping', 'dokan'), '<strong>' . wc_price($total_shipping) . '</strong>')), 'worth_of_coupons_used' => array('title' => sprintf(__('%s worth of coupons used', 'dokan'), '<strong>' . wc_price($total_coupons) . '</strong>'))));
    ?>
    <div id="poststuff" class="dokan-reports-wrap">
        <div class="dokan-reports-sidebar report-left dokan-left">
            <ul class="chart-legend">
                <?php 
    foreach ($legend as $item) {
        printf('<li>%s</li>', $item['title']);
    }
    ?>
            </ul>
        </div>

        <div class="dokan-reports-main report-right dokan-right">
            <div class="postbox">
                <h3><span><?php 
    echo $heading;
    ?>
</span></h3>

                <?php 
    dokan_sales_overview_chart_data($start_date, $end_date, 'day');
    ?>
            </div>
        </div>
    </div>
    <?php 
}
Пример #2
0
/**
 * Generate seller dashboard overview chart
 *
 * @since 1.0
 * @return void
 */
function dokan_dashboard_sales_overview()
{
    $start_date = date('Y-m-01', current_time('timestamp'));
    $end_date = date('Y-m-d', strtotime('midnight', current_time('timestamp')));
    dokan_sales_overview_chart_data($start_date, $end_date, 'day');
}