|
@@ 1454-1468 (lines=15) @@
|
| 1451 |
|
* @param bool $round (default: true). |
| 1452 |
|
* @return float |
| 1453 |
|
*/ |
| 1454 |
|
public function get_line_subtotal( $item, $inc_tax = false, $round = true ) { |
| 1455 |
|
$subtotal = 0; |
| 1456 |
|
|
| 1457 |
|
if ( is_callable( array( $item, 'get_subtotal' ) ) ) { |
| 1458 |
|
if ( $inc_tax ) { |
| 1459 |
|
$subtotal = $item->get_subtotal() + $item->get_subtotal_tax(); |
| 1460 |
|
} else { |
| 1461 |
|
$subtotal = $item->get_subtotal(); |
| 1462 |
|
} |
| 1463 |
|
|
| 1464 |
|
$subtotal = $round ? round( $subtotal, wc_get_price_decimals() ) : $subtotal; |
| 1465 |
|
} |
| 1466 |
|
|
| 1467 |
|
return apply_filters( 'woocommerce_order_amount_line_subtotal', $subtotal, $this, $item, $inc_tax, $round ); |
| 1468 |
|
} |
| 1469 |
|
|
| 1470 |
|
/** |
| 1471 |
|
* Calculate item cost - useful for gateways. |
|
@@ 1502-1514 (lines=13) @@
|
| 1499 |
|
* @param bool $round (default: true). |
| 1500 |
|
* @return float |
| 1501 |
|
*/ |
| 1502 |
|
public function get_line_total( $item, $inc_tax = false, $round = true ) { |
| 1503 |
|
$total = 0; |
| 1504 |
|
|
| 1505 |
|
if ( is_callable( array( $item, 'get_total' ) ) ) { |
| 1506 |
|
// Check if we need to add line tax to the line total. |
| 1507 |
|
$total = $inc_tax ? $item->get_total() + $item->get_total_tax() : $item->get_total(); |
| 1508 |
|
|
| 1509 |
|
// Check if we need to round. |
| 1510 |
|
$total = $round ? round( $total, wc_get_price_decimals() ) : $total; |
| 1511 |
|
} |
| 1512 |
|
|
| 1513 |
|
return apply_filters( 'woocommerce_order_amount_line_total', $total, $this, $item, $inc_tax, $round ); |
| 1514 |
|
} |
| 1515 |
|
|
| 1516 |
|
/** |
| 1517 |
|
* Get item tax - useful for gateways. |