Code Duplication    Length = 13-14 lines in 3 locations

includes/class-wc-order.php 3 locations

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