Code Duplication    Length = 11-11 lines in 3 locations

includes/class-wc-order.php 3 locations

@@ 1498-1508 (lines=11) @@
1495
	 * @param  string $item_type type of the item we're checking, if not a line_item
1496
	 * @return integer
1497
	 */
1498
	public function get_qty_refunded_for_item( $item_id, $item_type = 'line_item' ) {
1499
		$qty = 0;
1500
		foreach ( $this->get_refunds() as $refund ) {
1501
			foreach ( $refund->get_items( $item_type ) as $refunded_item ) {
1502
				if ( absint( $refunded_item->get_meta( '_refunded_item_id' ) ) === $item_id ) {
1503
					$qty += $refunded_item->get_quantity();
1504
				}
1505
			}
1506
		}
1507
		return $qty;
1508
	}
1509
1510
	/**
1511
	 * Get the refunded amount for a line item.
@@ 1517-1527 (lines=11) @@
1514
	 * @param  string $item_type type of the item we're checking, if not a line_item
1515
	 * @return integer
1516
	 */
1517
	public function get_total_refunded_for_item( $item_id, $item_type = 'line_item' ) {
1518
		$total = 0;
1519
		foreach ( $this->get_refunds() as $refund ) {
1520
			foreach ( $refund->get_items( $item_type ) as $refunded_item ) {
1521
				if ( absint( $refunded_item->get_meta( '_refunded_item_id' ) ) === $item_id ) {
1522
					$total += $refunded_item->get_total();
1523
				}
1524
			}
1525
		}
1526
		return $total * -1;
1527
	}
1528
1529
	/**
1530
	 * Get the refunded amount for a line item.
@@ 1537-1547 (lines=11) @@
1534
	 * @param  string $item_type type of the item we're checking, if not a line_item
1535
	 * @return double
1536
	 */
1537
	public function get_tax_refunded_for_item( $item_id, $tax_id, $item_type = 'line_item' ) {
1538
		$total = 0;
1539
		foreach ( $this->get_refunds() as $refund ) {
1540
			foreach ( $refund->get_items( $item_type ) as $refunded_item ) {
1541
				if ( absint( $refunded_item->get_meta( '_refunded_item_id' ) ) === $item_id ) {
1542
					$total += $refunded_item->get_total_tax();
1543
				}
1544
			}
1545
		}
1546
		return wc_round_tax_total( $total ) * -1;
1547
	}
1548
1549
	/**
1550
	 * Get total tax refunded by rate ID.