Code Duplication    Length = 13-14 lines in 3 locations

includes/class-wc-order.php 3 locations

@@ 1394-1406 (lines=13) @@
1391
	 * @since 2.2
1392
	 * @return string
1393
	 */
1394
	public function get_total_refunded() {
1395
		global $wpdb;
1396
1397
		$total = $wpdb->get_var( $wpdb->prepare( "
1398
			SELECT SUM( postmeta.meta_value )
1399
			FROM $wpdb->postmeta AS postmeta
1400
			INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d )
1401
			WHERE postmeta.meta_key = '_refund_amount'
1402
			AND postmeta.post_id = posts.ID
1403
		", $this->get_id() ) );
1404
1405
		return $total;
1406
	}
1407
1408
	/**
1409
	 * Get the total tax refunded.
@@ 1414-1427 (lines=14) @@
1411
	 * @since  2.3
1412
	 * @return float
1413
	 */
1414
	public function get_total_tax_refunded() {
1415
		global $wpdb;
1416
1417
		$total = $wpdb->get_var( $wpdb->prepare( "
1418
			SELECT SUM( order_itemmeta.meta_value )
1419
			FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta
1420
			INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d )
1421
			INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'tax' )
1422
			WHERE order_itemmeta.order_item_id = order_items.order_item_id
1423
			AND order_itemmeta.meta_key IN ('tax_amount', 'shipping_tax_amount')
1424
		", $this->get_id() ) );
1425
1426
		return abs( $total );
1427
	}
1428
1429
	/**
1430
	 * Get the total shipping refunded.
@@ 1435-1448 (lines=14) @@
1432
	 * @since  2.4
1433
	 * @return float
1434
	 */
1435
	public function get_total_shipping_refunded() {
1436
		global $wpdb;
1437
1438
		$total = $wpdb->get_var( $wpdb->prepare( "
1439
			SELECT SUM( order_itemmeta.meta_value )
1440
			FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta
1441
			INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d )
1442
			INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'shipping' )
1443
			WHERE order_itemmeta.order_item_id = order_items.order_item_id
1444
			AND order_itemmeta.meta_key IN ('cost')
1445
		", $this->get_id() ) );
1446
1447
		return abs( $total );
1448
	}
1449
1450
	/**
1451
	 * Gets the count of order items of a certain type that have been refunded.