|
@@ 1464-1476 (lines=13) @@
|
| 1461 |
|
* @since 2.2 |
| 1462 |
|
* @return string |
| 1463 |
|
*/ |
| 1464 |
|
public function get_total_refunded() { |
| 1465 |
|
global $wpdb; |
| 1466 |
|
|
| 1467 |
|
$total = $wpdb->get_var( $wpdb->prepare( " |
| 1468 |
|
SELECT SUM( postmeta.meta_value ) |
| 1469 |
|
FROM $wpdb->postmeta AS postmeta |
| 1470 |
|
INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d ) |
| 1471 |
|
WHERE postmeta.meta_key = '_refund_amount' |
| 1472 |
|
AND postmeta.post_id = posts.ID |
| 1473 |
|
", $this->get_id() ) ); |
| 1474 |
|
|
| 1475 |
|
return $total; |
| 1476 |
|
} |
| 1477 |
|
|
| 1478 |
|
/** |
| 1479 |
|
* Get the total tax refunded. |
|
@@ 1484-1497 (lines=14) @@
|
| 1481 |
|
* @since 2.3 |
| 1482 |
|
* @return float |
| 1483 |
|
*/ |
| 1484 |
|
public function get_total_tax_refunded() { |
| 1485 |
|
global $wpdb; |
| 1486 |
|
|
| 1487 |
|
$total = $wpdb->get_var( $wpdb->prepare( " |
| 1488 |
|
SELECT SUM( order_itemmeta.meta_value ) |
| 1489 |
|
FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta |
| 1490 |
|
INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d ) |
| 1491 |
|
INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'tax' ) |
| 1492 |
|
WHERE order_itemmeta.order_item_id = order_items.order_item_id |
| 1493 |
|
AND order_itemmeta.meta_key IN ('tax_amount', 'shipping_tax_amount') |
| 1494 |
|
", $this->get_id() ) ); |
| 1495 |
|
|
| 1496 |
|
return abs( $total ); |
| 1497 |
|
} |
| 1498 |
|
|
| 1499 |
|
/** |
| 1500 |
|
* Get the total shipping refunded. |
|
@@ 1505-1518 (lines=14) @@
|
| 1502 |
|
* @since 2.4 |
| 1503 |
|
* @return float |
| 1504 |
|
*/ |
| 1505 |
|
public function get_total_shipping_refunded() { |
| 1506 |
|
global $wpdb; |
| 1507 |
|
|
| 1508 |
|
$total = $wpdb->get_var( $wpdb->prepare( " |
| 1509 |
|
SELECT SUM( order_itemmeta.meta_value ) |
| 1510 |
|
FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta |
| 1511 |
|
INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d ) |
| 1512 |
|
INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'shipping' ) |
| 1513 |
|
WHERE order_itemmeta.order_item_id = order_items.order_item_id |
| 1514 |
|
AND order_itemmeta.meta_key IN ('cost') |
| 1515 |
|
", $this->get_id() ) ); |
| 1516 |
|
|
| 1517 |
|
return abs( $total ); |
| 1518 |
|
} |
| 1519 |
|
|
| 1520 |
|
/** |
| 1521 |
|
* Gets the count of order items of a certain type that have been refunded. |