Make qty for refunds negative
Fixes order counts reported in #10135 May however require an upgrade routine and needs more testing. Not for 2.5. Fixes #10135
This commit is contained in:
parent
6cc700a497
commit
77e1aa8263
|
@ -170,7 +170,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
echo ( isset( $item['qty'] ) ) ? esc_html( $item['qty'] ) : '';
|
||||
|
||||
if ( $refunded_qty = $order->get_qty_refunded_for_item( $item_id ) ) {
|
||||
echo '<small class="refunded">-' . $refunded_qty . '</small>';
|
||||
echo '<small class="refunded">' . $refunded_qty . '</small>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
|
|
@ -191,7 +191,7 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
|
|||
'order_by' => 'post_date ASC',
|
||||
'query_type' => 'get_results',
|
||||
'filter_range' => true,
|
||||
'order_types' => wc_get_order_types( 'sales-reports' ), // Orders, not refunds
|
||||
'order_types' => wc_get_order_types( 'sales-reports' ),
|
||||
'order_status' => array( 'completed', 'processing', 'on-hold', 'refunded' )
|
||||
) );
|
||||
|
||||
|
@ -343,7 +343,7 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
|
|||
$this->report_data->total_refunded_orders = absint( count( $this->report_data->full_refunds ) );
|
||||
|
||||
// Item counts
|
||||
$this->report_data->total_items = absint( array_sum( wp_list_pluck( $this->report_data->order_items, 'order_item_count' ) ) );
|
||||
$this->report_data->total_items = absint( array_sum( wp_list_pluck( $this->report_data->order_items, 'order_item_count' ) ) ) - $this->report_data->refunded_order_items;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -99,7 +99,6 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
|
|||
)
|
||||
),
|
||||
'query_type' => 'get_var',
|
||||
'order_types' => wc_get_order_types( 'order-count' ),
|
||||
'filter_range' => true
|
||||
) ) );
|
||||
|
||||
|
@ -110,7 +109,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
|
|||
);
|
||||
|
||||
$legend[] = array(
|
||||
'title' => sprintf( __( '%s purchases for the selected items', 'woocommerce' ), '<strong>' . $total_items . '</strong>' ),
|
||||
'title' => sprintf( __( '%s purchases for the selected items', 'woocommerce' ), '<strong>' . ( $total_items ) . '</strong>' ),
|
||||
'color' => $this->chart_colours['item_count'],
|
||||
'highlight_series' => 0
|
||||
);
|
||||
|
@ -230,20 +229,11 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
|
|||
'name' => 'order_item_qty'
|
||||
)
|
||||
),
|
||||
'where_meta' => array(
|
||||
array(
|
||||
'type' => 'order_item_meta',
|
||||
'meta_key' => '_line_subtotal',
|
||||
'meta_value' => '0',
|
||||
'operator' => '>'
|
||||
)
|
||||
),
|
||||
'order_by' => 'order_item_qty DESC',
|
||||
'group_by' => 'product_id',
|
||||
'limit' => 12,
|
||||
'query_type' => 'get_results',
|
||||
'filter_range' => true,
|
||||
'order_types' => wc_get_order_types( 'order-count' ),
|
||||
'filter_range' => true
|
||||
) );
|
||||
|
||||
if ( $top_sellers ) {
|
||||
|
@ -291,9 +281,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
|
|||
'group_by' => 'product_id',
|
||||
'limit' => 12,
|
||||
'query_type' => 'get_results',
|
||||
'filter_range' => true,
|
||||
'order_types' => wc_get_order_types( 'order-count' ),
|
||||
'nocache' => true
|
||||
'filter_range' => true
|
||||
) );
|
||||
|
||||
if ( $top_freebies ) {
|
||||
|
|
|
@ -689,7 +689,7 @@ function wc_create_refund( $args = array() ) {
|
|||
'tax_data' => array( 'total' => array_map( 'wc_format_refund_total', $refund_item['refund_tax'] ), 'subtotal' => array_map( 'wc_format_refund_total', $refund_item['refund_tax'] ) )
|
||||
)
|
||||
);
|
||||
$new_item_id = $refund->add_product( $order->get_product_from_item( $order_items[ $refund_item_id ] ), isset( $refund_item['qty'] ) ? $refund_item['qty'] : 0, $line_item_args );
|
||||
$new_item_id = $refund->add_product( $order->get_product_from_item( $order_items[ $refund_item_id ] ), isset( $refund_item['qty'] ) ? $refund_item['qty'] * -1 : 0, $line_item_args );
|
||||
wc_add_order_item_meta( $new_item_id, '_refunded_item_id', $refund_item_id );
|
||||
break;
|
||||
case 'shipping' :
|
||||
|
|
Loading…
Reference in New Issue