Code Duplication    Length = 13-14 lines in 3 locations

includes/class-wc-order.php 3 locations

@@ 1247-1259 (lines=13) @@
1244
	 * @since 2.2
1245
	 * @return string
1246
	 */
1247
	public function get_total_refunded() {
1248
		global $wpdb;
1249
1250
		$total = $wpdb->get_var( $wpdb->prepare( "
1251
			SELECT SUM( postmeta.meta_value )
1252
			FROM $wpdb->postmeta AS postmeta
1253
			INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d )
1254
			WHERE postmeta.meta_key = '_refund_amount'
1255
			AND postmeta.post_id = posts.ID
1256
		", $this->get_id() ) );
1257
1258
		return $total;
1259
	}
1260
1261
	/**
1262
	 * Get the total tax refunded.
@@ 1267-1280 (lines=14) @@
1264
	 * @since  2.3
1265
	 * @return float
1266
	 */
1267
	public function get_total_tax_refunded() {
1268
		global $wpdb;
1269
1270
		$total = $wpdb->get_var( $wpdb->prepare( "
1271
			SELECT SUM( order_itemmeta.meta_value )
1272
			FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta
1273
			INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d )
1274
			INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'tax' )
1275
			WHERE order_itemmeta.order_item_id = order_items.order_item_id
1276
			AND order_itemmeta.meta_key IN ('tax_amount', 'shipping_tax_amount')
1277
		", $this->get_id() ) );
1278
1279
		return abs( $total );
1280
	}
1281
1282
	/**
1283
	 * Get the total shipping refunded.
@@ 1288-1301 (lines=14) @@
1285
	 * @since  2.4
1286
	 * @return float
1287
	 */
1288
	public function get_total_shipping_refunded() {
1289
		global $wpdb;
1290
1291
		$total = $wpdb->get_var( $wpdb->prepare( "
1292
			SELECT SUM( order_itemmeta.meta_value )
1293
			FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta
1294
			INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d )
1295
			INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'shipping' )
1296
			WHERE order_itemmeta.order_item_id = order_items.order_item_id
1297
			AND order_itemmeta.meta_key IN ('cost')
1298
		", $this->get_id() ) );
1299
1300
		return abs( $total );
1301
	}
1302
1303
	/**
1304
	 * Gets the count of order items of a certain type that have been refunded.