Code Duplication    Length = 11-11 lines in 3 locations

includes/class-wc-order.php 3 locations

@@ 1399-1409 (lines=11) @@
1396
	 * @param  string $item_type type of the item we're checking, if not a line_item
1397
	 * @return integer
1398
	 */
1399
	public function get_qty_refunded_for_item( $item_id, $item_type = 'line_item' ) {
1400
		$qty = 0;
1401
		foreach ( $this->get_refunds() as $refund ) {
1402
			foreach ( $refund->get_items( $item_type ) as $refunded_item ) {
1403
				if ( absint( $refunded_item->get_meta( '_refunded_item_id' ) ) === $item_id ) {
1404
					$qty += $refunded_item->get_qty();
1405
				}
1406
			}
1407
		}
1408
		return $qty;
1409
	}
1410
1411
	/**
1412
	 * Get the refunded amount for a line item.
@@ 1418-1428 (lines=11) @@
1415
	 * @param  string $item_type type of the item we're checking, if not a line_item
1416
	 * @return integer
1417
	 */
1418
	public function get_total_refunded_for_item( $item_id, $item_type = 'line_item' ) {
1419
		$total = 0;
1420
		foreach ( $this->get_refunds() as $refund ) {
1421
			foreach ( $refund->get_items( $item_type ) as $refunded_item ) {
1422
				if ( absint( $refunded_item->get_meta( '_refunded_item_id' ) ) === $item_id ) {
1423
					$total += $refunded_item->get_total();
1424
				}
1425
			}
1426
		}
1427
		return $total * -1;
1428
	}
1429
1430
	/**
1431
	 * Get the refunded amount for a line item.
@@ 1438-1448 (lines=11) @@
1435
	 * @param  string $item_type type of the item we're checking, if not a line_item
1436
	 * @return double
1437
	 */
1438
	public function get_tax_refunded_for_item( $item_id, $tax_id, $item_type = 'line_item' ) {
1439
		$total = 0;
1440
		foreach ( $this->get_refunds() as $refund ) {
1441
			foreach ( $refund->get_items( $item_type ) as $refunded_item ) {
1442
				if ( absint( $refunded_item->get_meta( '_refunded_item_id' ) ) === $item_id ) {
1443
					$total += $refunded_item->get_total_tax();
1444
				}
1445
			}
1446
		}
1447
		return wc_round_tax_total( $total ) * -1;
1448
	}
1449
1450
	/**
1451
	 * Get total tax refunded by rate ID.