Code Duplication    Length = 13-14 lines in 3 locations

includes/class-wc-order.php 3 locations

@@ 1295-1307 (lines=13) @@
1292
	 * @since 2.2
1293
	 * @return string
1294
	 */
1295
	public function get_total_refunded() {
1296
		global $wpdb;
1297
1298
		$total = $wpdb->get_var( $wpdb->prepare( "
1299
			SELECT SUM( postmeta.meta_value )
1300
			FROM $wpdb->postmeta AS postmeta
1301
			INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d )
1302
			WHERE postmeta.meta_key = '_refund_amount'
1303
			AND postmeta.post_id = posts.ID
1304
		", $this->get_id() ) );
1305
1306
		return $total;
1307
	}
1308
1309
	/**
1310
	 * Get the total tax refunded.
@@ 1315-1328 (lines=14) @@
1312
	 * @since  2.3
1313
	 * @return float
1314
	 */
1315
	public function get_total_tax_refunded() {
1316
		global $wpdb;
1317
1318
		$total = $wpdb->get_var( $wpdb->prepare( "
1319
			SELECT SUM( order_itemmeta.meta_value )
1320
			FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta
1321
			INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d )
1322
			INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'tax' )
1323
			WHERE order_itemmeta.order_item_id = order_items.order_item_id
1324
			AND order_itemmeta.meta_key IN ('tax_amount', 'shipping_tax_amount')
1325
		", $this->get_id() ) );
1326
1327
		return abs( $total );
1328
	}
1329
1330
	/**
1331
	 * Get the total shipping refunded.
@@ 1336-1349 (lines=14) @@
1333
	 * @since  2.4
1334
	 * @return float
1335
	 */
1336
	public function get_total_shipping_refunded() {
1337
		global $wpdb;
1338
1339
		$total = $wpdb->get_var( $wpdb->prepare( "
1340
			SELECT SUM( order_itemmeta.meta_value )
1341
			FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta
1342
			INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d )
1343
			INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'shipping' )
1344
			WHERE order_itemmeta.order_item_id = order_items.order_item_id
1345
			AND order_itemmeta.meta_key IN ('cost')
1346
		", $this->get_id() ) );
1347
1348
		return abs( $total );
1349
	}
1350
1351
	/**
1352
	 * Gets the count of order items of a certain type that have been refunded.