|
@@ 486-498 (lines=13) @@
|
| 483 |
|
* @since 2.2 |
| 484 |
|
* @return string |
| 485 |
|
*/ |
| 486 |
|
public function get_total_refunded() { |
| 487 |
|
global $wpdb; |
| 488 |
|
|
| 489 |
|
$total = $wpdb->get_var( $wpdb->prepare( " |
| 490 |
|
SELECT SUM( postmeta.meta_value ) |
| 491 |
|
FROM $wpdb->postmeta AS postmeta |
| 492 |
|
INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d ) |
| 493 |
|
WHERE postmeta.meta_key = '_refund_amount' |
| 494 |
|
AND postmeta.post_id = posts.ID |
| 495 |
|
", $this->get_id() ) ); |
| 496 |
|
|
| 497 |
|
return $total; |
| 498 |
|
} |
| 499 |
|
|
| 500 |
|
/** |
| 501 |
|
* Get the total tax refunded. |
|
@@ 506-519 (lines=14) @@
|
| 503 |
|
* @since 2.3 |
| 504 |
|
* @return float |
| 505 |
|
*/ |
| 506 |
|
public function get_total_tax_refunded() { |
| 507 |
|
global $wpdb; |
| 508 |
|
|
| 509 |
|
$total = $wpdb->get_var( $wpdb->prepare( " |
| 510 |
|
SELECT SUM( order_itemmeta.meta_value ) |
| 511 |
|
FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta |
| 512 |
|
INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d ) |
| 513 |
|
INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'tax' ) |
| 514 |
|
WHERE order_itemmeta.order_item_id = order_items.order_item_id |
| 515 |
|
AND order_itemmeta.meta_key IN ('tax_amount', 'shipping_tax_amount') |
| 516 |
|
", $this->get_id() ) ); |
| 517 |
|
|
| 518 |
|
return abs( $total ); |
| 519 |
|
} |
| 520 |
|
|
| 521 |
|
/** |
| 522 |
|
* Get the total shipping refunded. |
|
@@ 527-540 (lines=14) @@
|
| 524 |
|
* @since 2.4 |
| 525 |
|
* @return float |
| 526 |
|
*/ |
| 527 |
|
public function get_total_shipping_refunded() { |
| 528 |
|
global $wpdb; |
| 529 |
|
|
| 530 |
|
$total = $wpdb->get_var( $wpdb->prepare( " |
| 531 |
|
SELECT SUM( order_itemmeta.meta_value ) |
| 532 |
|
FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta |
| 533 |
|
INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d ) |
| 534 |
|
INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'shipping' ) |
| 535 |
|
WHERE order_itemmeta.order_item_id = order_items.order_item_id |
| 536 |
|
AND order_itemmeta.meta_key IN ('cost') |
| 537 |
|
", $this->get_id() ) ); |
| 538 |
|
|
| 539 |
|
return abs( $total ); |
| 540 |
|
} |
| 541 |
|
|
| 542 |
|
/** |
| 543 |
|
* Gets the count of order items of a certain type that have been refunded. |