Code Duplication    Length = 13-14 lines in 3 locations

includes/class-wc-order.php 3 locations

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