Code Duplication    Length = 13-14 lines in 3 locations

includes/class-wc-order.php 3 locations

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