|
@@ 2421-2435 (lines=15) @@
|
| 2418 |
|
* @param bool $round (default: true). |
| 2419 |
|
* @return float |
| 2420 |
|
*/ |
| 2421 |
|
public function get_line_subtotal( $item, $inc_tax = false, $round = true ) { |
| 2422 |
|
$subtotal = 0; |
| 2423 |
|
|
| 2424 |
|
if ( is_callable( array( $item, 'get_subtotal' ) ) ) { |
| 2425 |
|
if ( $inc_tax ) { |
| 2426 |
|
$subtotal = $item->get_subtotal() + $item->get_subtotal_tax(); |
| 2427 |
|
} else { |
| 2428 |
|
$subtotal = $item->get_subtotal(); |
| 2429 |
|
} |
| 2430 |
|
|
| 2431 |
|
$subtotal = $round ? round( $subtotal, wc_get_price_decimals() ) : $subtotal; |
| 2432 |
|
} |
| 2433 |
|
|
| 2434 |
|
return apply_filters( 'woocommerce_order_amount_line_subtotal', $subtotal, $this, $item, $inc_tax, $round ); |
| 2435 |
|
} |
| 2436 |
|
|
| 2437 |
|
/** |
| 2438 |
|
* Calculate item cost - useful for gateways. |
|
@@ 2469-2481 (lines=13) @@
|
| 2466 |
|
* @param bool $round (default: true). |
| 2467 |
|
* @return float |
| 2468 |
|
*/ |
| 2469 |
|
public function get_line_total( $item, $inc_tax = false, $round = true ) { |
| 2470 |
|
$total = 0; |
| 2471 |
|
|
| 2472 |
|
if ( is_callable( array( $item, 'get_total' ) ) ) { |
| 2473 |
|
// Check if we need to add line tax to the line total. |
| 2474 |
|
$total = $inc_tax ? $item->get_total() + $item->get_total_tax() : $item->get_total(); |
| 2475 |
|
|
| 2476 |
|
// Check if we need to round. |
| 2477 |
|
$total = $round ? round( $total, wc_get_price_decimals() ) : $total; |
| 2478 |
|
} |
| 2479 |
|
|
| 2480 |
|
return apply_filters( 'woocommerce_order_amount_line_total', $total, $this, $item, $inc_tax, $round ); |
| 2481 |
|
} |
| 2482 |
|
|
| 2483 |
|
/** |
| 2484 |
|
* Get item tax - useful for gateways. |