|
@@ 1490-1504 (lines=15) @@
|
| 1487 |
|
* @param bool $round (default: true). |
| 1488 |
|
* @return float |
| 1489 |
|
*/ |
| 1490 |
|
public function get_line_subtotal( $item, $inc_tax = false, $round = true ) { |
| 1491 |
|
$subtotal = 0; |
| 1492 |
|
|
| 1493 |
|
if ( is_callable( array( $item, 'get_subtotal' ) ) ) { |
| 1494 |
|
if ( $inc_tax ) { |
| 1495 |
|
$subtotal = $item->get_subtotal() + $item->get_subtotal_tax(); |
| 1496 |
|
} else { |
| 1497 |
|
$subtotal = $item->get_subtotal(); |
| 1498 |
|
} |
| 1499 |
|
|
| 1500 |
|
$subtotal = $round ? round( $subtotal, wc_get_price_decimals() ) : $subtotal; |
| 1501 |
|
} |
| 1502 |
|
|
| 1503 |
|
return apply_filters( 'woocommerce_order_amount_line_subtotal', $subtotal, $this, $item, $inc_tax, $round ); |
| 1504 |
|
} |
| 1505 |
|
|
| 1506 |
|
/** |
| 1507 |
|
* Calculate item cost - useful for gateways. |
|
@@ 1538-1550 (lines=13) @@
|
| 1535 |
|
* @param bool $round (default: true). |
| 1536 |
|
* @return float |
| 1537 |
|
*/ |
| 1538 |
|
public function get_line_total( $item, $inc_tax = false, $round = true ) { |
| 1539 |
|
$total = 0; |
| 1540 |
|
|
| 1541 |
|
if ( is_callable( array( $item, 'get_total' ) ) ) { |
| 1542 |
|
// Check if we need to add line tax to the line total. |
| 1543 |
|
$total = $inc_tax ? $item->get_total() + $item->get_total_tax() : $item->get_total(); |
| 1544 |
|
|
| 1545 |
|
// Check if we need to round. |
| 1546 |
|
$total = $round ? round( $total, wc_get_price_decimals() ) : $total; |
| 1547 |
|
} |
| 1548 |
|
|
| 1549 |
|
return apply_filters( 'woocommerce_order_amount_line_total', $total, $this, $item, $inc_tax, $round ); |
| 1550 |
|
} |
| 1551 |
|
|
| 1552 |
|
/** |
| 1553 |
|
* Get item tax - useful for gateways. |