Adjust sales report to deal with partial shipping refunds and full refunds
This commit is contained in:
parent
049c95e724
commit
7d1a016502
|
@ -76,15 +76,23 @@ class WC_Admin_Report {
|
|||
$distinct = 'DISTINCT';
|
||||
}
|
||||
|
||||
if ( $value['type'] == 'meta' ) {
|
||||
switch ( $value['type'] ) {
|
||||
case 'meta' :
|
||||
$get_key = "meta_{$key}.meta_value";
|
||||
} elseif( $value['type'] == 'post_data' ) {
|
||||
break;
|
||||
case 'parent_meta' :
|
||||
$get_key = "parent_meta_{$key}.meta_value";
|
||||
break;
|
||||
case 'post_data' :
|
||||
$get_key = "posts.{$key}";
|
||||
} elseif( $value['type'] == 'order_item_meta' ) {
|
||||
break;
|
||||
case 'order_item_meta' :
|
||||
$get_key = "order_item_meta_{$key}.meta_value";
|
||||
} elseif( $value['type'] == 'order_item' ) {
|
||||
break;
|
||||
case 'order_item' :
|
||||
$get_key = "order_items.{$key}";
|
||||
} else {
|
||||
break;
|
||||
default :
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -103,42 +111,44 @@ class WC_Admin_Report {
|
|||
// Joins
|
||||
$joins = array();
|
||||
|
||||
foreach ( $data as $key => $value ) {
|
||||
|
||||
foreach ( ( $data + $where ) as $key => $value ) {
|
||||
$join_type = isset( $value['join_type'] ) ? $value['join_type'] : 'INNER';
|
||||
if ( $value['type'] == 'meta' ) {
|
||||
$joins["meta_{$key}"] = "{$join_type} JOIN {$wpdb->postmeta} AS meta_{$key} ON " .
|
||||
"(posts.ID = meta_{$key}.post_id) " .
|
||||
"AND (meta_{$key}.meta_key = '{$key}')";
|
||||
|
||||
} elseif ( $value['type'] == 'order_item_meta' ) {
|
||||
$type = isset( $value['type'] ) ? $value['type'] : false;
|
||||
|
||||
switch ( $type ) {
|
||||
case 'meta' :
|
||||
$joins["meta_{$key}"] = "{$join_type} JOIN {$wpdb->postmeta} AS meta_{$key} ON ( posts.ID = meta_{$key}.post_id AND meta_{$key}.meta_key = '{$key}' )";
|
||||
break;
|
||||
case 'parent_meta' :
|
||||
$joins["parent_meta_{$key}"] = "{$join_type} JOIN {$wpdb->postmeta} AS parent_meta_{$key} ON (posts.post_parent = parent_meta_{$key}.post_id) AND (parent_meta_{$key}.meta_key = '{$key}')";
|
||||
break;
|
||||
case 'order_item_meta' :
|
||||
$joins["order_items"] = "{$join_type} JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON (posts.ID = order_items.order_id)";
|
||||
if ( $value['order_item_type'] ) {
|
||||
|
||||
if ( ! empty( $value['order_item_type'] ) ) {
|
||||
$joins["order_items"] .= " AND (order_items.order_item_type = '{$value['order_item_type']}')";
|
||||
}
|
||||
|
||||
$joins["order_item_meta_{$key}"] = "{$join_type} JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_{$key} ON " .
|
||||
"(order_items.order_item_id = order_item_meta_{$key}.order_item_id) " .
|
||||
" AND (order_item_meta_{$key}.meta_key = '{$key}')";
|
||||
} elseif ( $value['type'] == 'order_item' ) {
|
||||
|
||||
break;
|
||||
case 'order_item' :
|
||||
$joins["order_items"] = "{$join_type} JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_items.order_id";
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $where_meta ) ) {
|
||||
|
||||
foreach ( $where_meta as $value ) {
|
||||
|
||||
if ( ! is_array( $value ) ) {
|
||||
continue;
|
||||
}
|
||||
$join_type = isset( $value['join_type'] ) ? $value['join_type'] : 'INNER';
|
||||
|
||||
$type = isset( $value['type'] ) ? $value['type'] : false;
|
||||
$key = is_array( $value['meta_key'] ) ? $value['meta_key'][0] . '_array' : $value['meta_key'];
|
||||
|
||||
if ( isset( $value['type'] ) && $value['type'] == 'order_item_meta' ) {
|
||||
if ( 'order_item_meta' === $type ) {
|
||||
|
||||
$joins["order_items"] = "{$join_type} JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_items.order_id";
|
||||
$joins["order_item_meta_{$key}"] = "{$join_type} JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_{$key} ON order_items.order_item_id = order_item_meta_{$key}.order_item_id";
|
||||
|
|
|
@ -29,84 +29,6 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
|
|||
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(
|
||||
|
@ -163,38 +85,6 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
|
|||
'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(
|
||||
|
@ -225,21 +115,17 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
|
|||
'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(
|
||||
/**
|
||||
* Get total of fully refunded items.
|
||||
*/
|
||||
$this->report_data->refunded_order_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_count',
|
||||
'join_type' => 'LEFT'
|
||||
),
|
||||
'post_date' => array(
|
||||
'type' => 'post_data',
|
||||
'function' => '',
|
||||
'name' => 'post_date'
|
||||
),
|
||||
'name' => 'order_item_count'
|
||||
)
|
||||
),
|
||||
'where' => array(
|
||||
array(
|
||||
|
@ -248,44 +134,178 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
|
|||
'operator' => '='
|
||||
)
|
||||
),
|
||||
'group_by' => $this->group_by_query,
|
||||
'order_by' => 'post_date ASC',
|
||||
'query_type' => 'get_results',
|
||||
'query_type' => 'get_var',
|
||||
'filter_range' => true,
|
||||
'order_types' => wc_get_order_types( 'order-count' ),
|
||||
'order_status' => array( 'refunded' ),
|
||||
) );
|
||||
'order_status' => array( 'refunded' )
|
||||
) ) );
|
||||
|
||||
// All partially refunded items
|
||||
$this->report_data->partially_refunded_order_items = (array) $this->get_order_report_data( array(
|
||||
/**
|
||||
* Order totals by date. Charts should show GROSS amounts to avoid going -ve.
|
||||
*/
|
||||
$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'
|
||||
),
|
||||
'_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_types' => wc_get_order_types( 'sales-reports' ), // Orders, not refunds
|
||||
'order_status' => array( 'completed', 'processing', 'on-hold', 'refunded' )
|
||||
) );
|
||||
|
||||
/**
|
||||
* If an order is 100% refunded we should look at the parent's totals, but the refunds dates.
|
||||
* We also need to ensure each parent order's values are only counted/summed once.
|
||||
*/
|
||||
$this->report_data->full_refunds = (array) $this->get_order_report_data( array(
|
||||
'data' => array(
|
||||
'_order_total' => array(
|
||||
'type' => 'parent_meta',
|
||||
'function' => '',
|
||||
'name' => 'total_refund'
|
||||
),
|
||||
'_order_shipping' => array(
|
||||
'type' => 'parent_meta',
|
||||
'function' => '',
|
||||
'name' => 'total_shipping'
|
||||
),
|
||||
'_order_tax' => array(
|
||||
'type' => 'parent_meta',
|
||||
'function' => '',
|
||||
'name' => 'total_tax'
|
||||
),
|
||||
'_order_shipping_tax' => array(
|
||||
'type' => 'parent_meta',
|
||||
'function' => '',
|
||||
'name' => 'total_shipping_tax'
|
||||
),
|
||||
'post_date' => array(
|
||||
'type' => 'post_data',
|
||||
'function' => '',
|
||||
'name' => 'post_date'
|
||||
)
|
||||
),
|
||||
'group_by' => 'posts.post_parent',
|
||||
'query_type' => 'get_results',
|
||||
'filter_range' => true,
|
||||
'order_status' => false,
|
||||
'parent_order_status' => array( 'refunded' )
|
||||
) );
|
||||
|
||||
/**
|
||||
* Partial refunds. This includes line items, shipping and taxes. Not grouped by date.
|
||||
*/
|
||||
$this->report_data->partial_refunds = (array) $this->get_order_report_data( array(
|
||||
'data' => array(
|
||||
'ID' => array(
|
||||
'type' => 'post_data',
|
||||
'function' => '',
|
||||
'name' => 'refund_id'
|
||||
),
|
||||
'_refund_amount' => array(
|
||||
'type' => 'meta',
|
||||
'function' => '',
|
||||
'name' => 'total_refund'
|
||||
),
|
||||
'post_date' => array(
|
||||
'type' => 'post_data',
|
||||
'function' => '',
|
||||
'name' => 'post_date'
|
||||
),
|
||||
'order_item_type' => array(
|
||||
'type' => 'order_item',
|
||||
'function' => '',
|
||||
'name' => 'item_type',
|
||||
'join_type' => 'LEFT'
|
||||
),
|
||||
'_order_total' => array(
|
||||
'type' => 'meta',
|
||||
'function' => '',
|
||||
'name' => 'total_sales'
|
||||
),
|
||||
'_order_shipping' => array(
|
||||
'type' => 'meta',
|
||||
'function' => '',
|
||||
'name' => 'total_shipping'
|
||||
),
|
||||
'_order_tax' => array(
|
||||
'type' => 'meta',
|
||||
'function' => '',
|
||||
'name' => 'total_tax'
|
||||
),
|
||||
'_order_shipping_tax' => array(
|
||||
'type' => 'meta',
|
||||
'function' => '',
|
||||
'name' => 'total_shipping_tax'
|
||||
),
|
||||
'_qty' => array(
|
||||
'type' => 'order_item_meta',
|
||||
'function' => 'SUM',
|
||||
'name' => 'order_item_count',
|
||||
'join_type' => 'LEFT'
|
||||
)
|
||||
),
|
||||
'group_by' => 'refund_id',
|
||||
'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 );
|
||||
/**
|
||||
* Total up values by combining full refunds and partial refunds for line items.
|
||||
*/
|
||||
$this->report_data->total_tax_refunded = wc_format_decimal( array_sum( wp_list_pluck( $this->report_data->full_refunds, 'total_tax' ) ), 2 );
|
||||
$this->report_data->total_shipping_refunded = wc_format_decimal( array_sum( wp_list_pluck( $this->report_data->full_refunds, 'total_shipping' ) ), 2 );
|
||||
$this->report_data->total_shipping_tax_refunded = wc_format_decimal( array_sum( wp_list_pluck( $this->report_data->full_refunds, 'total_shipping_tax' ) ), 2 );
|
||||
$this->report_data->total_refunds = wc_format_decimal( array_sum( wp_list_pluck( $this->report_data->full_refunds, 'total_refund' ) ), 2 );
|
||||
|
||||
// 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 );
|
||||
/**
|
||||
* Loop over partial refunds and increase the above values.
|
||||
*/
|
||||
foreach ( $this->report_data->partial_refunds as $key => $value ) {
|
||||
switch ( $value->item_type ) {
|
||||
case 'shipping' :
|
||||
$this->report_data->total_shipping_tax_refunded += ( $value->total_shipping_tax * -1 );
|
||||
$this->report_data->total_shipping_refunded += wc_format_decimal( $value->total_refund, 2 );
|
||||
$this->report_data->total_refunds += $value->total_refund;
|
||||
|
||||
|
||||
break;
|
||||
case 'line_item' :
|
||||
$this->report_data->total_tax_refunded += ( $value->total_tax * -1 );
|
||||
$this->report_data->refunded_order_items += absint( $value->order_item_count );
|
||||
$this->report_data->total_refunds += $value->total_refund;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 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 );
|
||||
|
@ -293,7 +313,6 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
|
|||
$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 );
|
||||
|
||||
|
@ -303,10 +322,9 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
|
|||
// 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' ) ) );
|
||||
$this->report_data->total_refunded_orders = absint( count( $this->report_data->full_refunds ) );
|
||||
|
||||
// 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' ) ) );
|
||||
}
|
||||
|
||||
|
@ -358,17 +376,16 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
|
|||
'color' => $this->chart_colours['item_count'],
|
||||
'highlight_series' => 0
|
||||
);
|
||||
|
||||
$legend[] = array(
|
||||
'title' => sprintf( _n( '%s refunded %d order', '%s refunded %d orders', $this->report_data->total_refunded_orders, 'woocommerce' ), '<strong>' . wc_price( $data->total_refunds ) . '</strong>', $this->report_data->total_refunded_orders ) . ' (' . sprintf( _n( '%d item', '%d items', $this->report_data->refunded_order_items, 'woocommerce' ), $this->report_data->refunded_order_items ) . ')',
|
||||
'color' => $this->chart_colours['refund_amount'],
|
||||
'highlight_series' => 4
|
||||
);
|
||||
$legend[] = array(
|
||||
'title' => sprintf( __( '%s charged for shipping', 'woocommerce' ), '<strong>' . wc_price( $data->total_shipping ) . '</strong>' ),
|
||||
'color' => $this->chart_colours['shipping_amount'],
|
||||
'highlight_series' => 5
|
||||
);
|
||||
$legend[] = array(
|
||||
'title' => sprintf( _n( '%s refunded %d order', '%s refunded %d orders', $this->report_data->total_refunded_orders, 'woocommerce' ), '<strong>' . wc_price( $data->total_refunds ) . '</strong>', $this->report_data->total_refunded_orders ) . ' (' . sprintf( _n( '%d item', '%d items', $this->report_data->total_item_refunds, 'woocommerce' ), $this->report_data->total_item_refunds ) . ')',
|
||||
'color' => $this->chart_colours['refund_amount'],
|
||||
'highlight_series' => 4
|
||||
);
|
||||
$legend[] = array(
|
||||
'title' => sprintf( __( '%s worth of coupons used', 'woocommerce' ), '<strong>' . wc_price( $data->total_coupons ) . '</strong>' ),
|
||||
'color' => $this->chart_colours['coupon_amount'],
|
||||
|
@ -458,7 +475,7 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
|
|||
$order_amounts = $this->prepare_chart_data( $this->report_data->orders, 'post_date', 'total_sales', $this->chart_interval, $this->start_date, $this->chart_groupby );
|
||||
$coupon_amounts = $this->prepare_chart_data( $this->report_data->coupons, 'post_date', 'discount_amount', $this->chart_interval, $this->start_date, $this->chart_groupby );
|
||||
$shipping_amounts = $this->prepare_chart_data( $this->report_data->orders, 'post_date', 'total_shipping', $this->chart_interval, $this->start_date, $this->chart_groupby );
|
||||
$refund_amounts = $this->prepare_chart_data( $this->report_data->refunds, 'post_date', 'total_refund', $this->chart_interval, $this->start_date, $this->chart_groupby );
|
||||
$refund_amounts = $this->prepare_chart_data( array_merge( $this->report_data->partial_refunds, $this->report_data->full_refunds ), 'post_date', 'total_refund', $this->chart_interval, $this->start_date, $this->chart_groupby );
|
||||
$shipping_tax_amounts = $this->prepare_chart_data( $this->report_data->orders, 'post_date', 'total_shipping_tax', $this->chart_interval, $this->start_date, $this->chart_groupby );
|
||||
$tax_amounts = $this->prepare_chart_data( $this->report_data->orders, 'post_date', 'total_tax', $this->chart_interval, $this->start_date, $this->chart_groupby );
|
||||
|
||||
|
@ -527,16 +544,6 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
|
|||
shadowSize: 0,
|
||||
<?php echo $this->get_currency_tooltip(); ?>
|
||||
},
|
||||
{
|
||||
label: "<?php echo esc_js( __( 'Refund amount', 'woocommerce' ) ) ?>",
|
||||
data: order_data.refund_amounts,
|
||||
yaxis: 2,
|
||||
color: '<?php echo $this->chart_colours['refund_amount']; ?>',
|
||||
points: { show: true, radius: 5, lineWidth: 2, fillColor: '#fff', fill: true },
|
||||
lines: { show: true, lineWidth: 2, fill: false },
|
||||
shadowSize: 0,
|
||||
prepend_tooltip: "<?php echo get_woocommerce_currency_symbol(); ?>"
|
||||
},
|
||||
{
|
||||
label: "<?php echo esc_js( __( 'Shipping amount', 'woocommerce' ) ) ?>",
|
||||
data: order_data.shipping_amounts,
|
||||
|
@ -566,7 +573,17 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
|
|||
lines: { show: true, lineWidth: 5, fill: false },
|
||||
shadowSize: 0,
|
||||
<?php echo $this->get_currency_tooltip(); ?>
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "<?php echo esc_js( __( 'Refund amount', 'woocommerce' ) ) ?>",
|
||||
data: order_data.refund_amounts,
|
||||
yaxis: 2,
|
||||
color: '<?php echo $this->chart_colours['refund_amount']; ?>',
|
||||
points: { show: true, radius: 5, lineWidth: 2, fillColor: '#fff', fill: true },
|
||||
lines: { show: true, lineWidth: 2, fill: false },
|
||||
shadowSize: 0,
|
||||
prepend_tooltip: "<?php echo get_woocommerce_currency_symbol(); ?>"
|
||||
},
|
||||
];
|
||||
|
||||
if ( highlight !== 'undefined' && series[ highlight ] ) {
|
||||
|
@ -574,8 +591,9 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
|
|||
|
||||
highlight_series.color = '#9c5d90';
|
||||
|
||||
if ( highlight_series.bars )
|
||||
if ( highlight_series.bars ) {
|
||||
highlight_series.bars.fillColor = '#9c5d90';
|
||||
}
|
||||
|
||||
if ( highlight_series.lines ) {
|
||||
highlight_series.lines.lineWidth = 5;
|
||||
|
|
|
@ -88,6 +88,8 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
|
|||
|
||||
if ( $refund_id ) {
|
||||
$this->refund = wc_get_order( $refund_id );
|
||||
} else {
|
||||
$this->refund = false;
|
||||
}
|
||||
|
||||
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
|
||||
|
|
Loading…
Reference in New Issue