Code Duplication    Length = 13-14 lines in 3 locations

includes/class-wc-order.php 3 locations

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