@@ 1543-1557 (lines=15) @@ | ||
1540 | * @param bool $round (default: true). |
|
1541 | * @return float |
|
1542 | */ |
|
1543 | public function get_item_subtotal( $item, $inc_tax = false, $round = true ) { |
|
1544 | $subtotal = 0; |
|
1545 | ||
1546 | if ( is_callable( array( $item, 'get_subtotal' ) ) && $item->get_quantity() ) { |
|
1547 | if ( $inc_tax ) { |
|
1548 | $subtotal = ( $item->get_subtotal() + $item->get_subtotal_tax() ) / $item->get_quantity(); |
|
1549 | } else { |
|
1550 | $subtotal = floatval( $item->get_subtotal() ) / $item->get_quantity(); |
|
1551 | } |
|
1552 | ||
1553 | $subtotal = $round ? number_format( (float) $subtotal, wc_get_price_decimals(), '.', '' ) : $subtotal; |
|
1554 | } |
|
1555 | ||
1556 | return apply_filters( 'woocommerce_order_amount_item_subtotal', $subtotal, $this, $item, $inc_tax, $round ); |
|
1557 | } |
|
1558 | ||
1559 | /** |
|
1560 | * Get line subtotal - this is the cost before discount. |
|
@@ 1591-1605 (lines=15) @@ | ||
1588 | * @param bool $round (default: true). |
|
1589 | * @return float |
|
1590 | */ |
|
1591 | public function get_item_total( $item, $inc_tax = false, $round = true ) { |
|
1592 | $total = 0; |
|
1593 | ||
1594 | if ( is_callable( array( $item, 'get_total' ) ) && $item->get_quantity() ) { |
|
1595 | if ( $inc_tax ) { |
|
1596 | $total = ( $item->get_total() + $item->get_total_tax() ) / $item->get_quantity(); |
|
1597 | } else { |
|
1598 | $total = floatval( $item->get_total() ) / $item->get_quantity(); |
|
1599 | } |
|
1600 | ||
1601 | $total = $round ? round( $total, wc_get_price_decimals() ) : $total; |
|
1602 | } |
|
1603 | ||
1604 | return apply_filters( 'woocommerce_order_amount_item_total', $total, $this, $item, $inc_tax, $round ); |
|
1605 | } |
|
1606 | ||
1607 | /** |
|
1608 | * Calculate line total - useful for gateways. |