@@ 81-93 (lines=13) @@ | ||
78 | * @since 2.2 |
|
79 | * @return string |
|
80 | */ |
|
81 | public function get_total_refunded() { |
|
82 | global $wpdb; |
|
83 | ||
84 | $total = $wpdb->get_var( $wpdb->prepare( " |
|
85 | SELECT SUM( postmeta.meta_value ) |
|
86 | FROM $wpdb->postmeta AS postmeta |
|
87 | INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d ) |
|
88 | WHERE postmeta.meta_key = '_refund_amount' |
|
89 | AND postmeta.post_id = posts.ID |
|
90 | ", $this->id ) ); |
|
91 | ||
92 | return $total; |
|
93 | } |
|
94 | ||
95 | /** |
|
96 | * Get the total tax refunded. |
|
@@ 101-114 (lines=14) @@ | ||
98 | * @since 2.3 |
|
99 | * @return float |
|
100 | */ |
|
101 | public function get_total_tax_refunded() { |
|
102 | global $wpdb; |
|
103 | ||
104 | $total = $wpdb->get_var( $wpdb->prepare( " |
|
105 | SELECT SUM( order_itemmeta.meta_value ) |
|
106 | FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta |
|
107 | INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d ) |
|
108 | INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'tax' ) |
|
109 | WHERE order_itemmeta.order_item_id = order_items.order_item_id |
|
110 | AND order_itemmeta.meta_key IN ('tax_amount', 'shipping_tax_amount') |
|
111 | ", $this->id ) ); |
|
112 | ||
113 | return abs( $total ); |
|
114 | } |
|
115 | ||
116 | /** |
|
117 | * Get the total shipping refunded. |
|
@@ 122-135 (lines=14) @@ | ||
119 | * @since 2.4 |
|
120 | * @return float |
|
121 | */ |
|
122 | public function get_total_shipping_refunded() { |
|
123 | global $wpdb; |
|
124 | ||
125 | $total = $wpdb->get_var( $wpdb->prepare( " |
|
126 | SELECT SUM( order_itemmeta.meta_value ) |
|
127 | FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta |
|
128 | INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d ) |
|
129 | INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'shipping' ) |
|
130 | WHERE order_itemmeta.order_item_id = order_items.order_item_id |
|
131 | AND order_itemmeta.meta_key IN ('cost') |
|
132 | ", $this->id ) ); |
|
133 | ||
134 | return abs( $total ); |
|
135 | } |
|
136 | ||
137 | /** |
|
138 | * Gets the count of order items of a certain type that have been refunded. |