|
@@ 2447-2461 (lines=15) @@
|
| 2444 |
|
* @param bool $round (default: true). |
| 2445 |
|
* @return float |
| 2446 |
|
*/ |
| 2447 |
|
public function get_line_subtotal( $item, $inc_tax = false, $round = true ) { |
| 2448 |
|
$subtotal = 0; |
| 2449 |
|
|
| 2450 |
|
if ( is_callable( array( $item, 'get_subtotal' ) ) ) { |
| 2451 |
|
if ( $inc_tax ) { |
| 2452 |
|
$subtotal = $item->get_subtotal() + $item->get_subtotal_tax(); |
| 2453 |
|
} else { |
| 2454 |
|
$subtotal = $item->get_subtotal(); |
| 2455 |
|
} |
| 2456 |
|
|
| 2457 |
|
$subtotal = $round ? round( $subtotal, wc_get_price_decimals() ) : $subtotal; |
| 2458 |
|
} |
| 2459 |
|
|
| 2460 |
|
return apply_filters( 'woocommerce_order_amount_line_subtotal', $subtotal, $this, $item, $inc_tax, $round ); |
| 2461 |
|
} |
| 2462 |
|
|
| 2463 |
|
/** |
| 2464 |
|
* Calculate item cost - useful for gateways. |
|
@@ 2495-2507 (lines=13) @@
|
| 2492 |
|
* @param bool $round (default: true). |
| 2493 |
|
* @return float |
| 2494 |
|
*/ |
| 2495 |
|
public function get_line_total( $item, $inc_tax = false, $round = true ) { |
| 2496 |
|
$total = 0; |
| 2497 |
|
|
| 2498 |
|
if ( is_callable( array( $item, 'get_total' ) ) ) { |
| 2499 |
|
// Check if we need to add line tax to the line total. |
| 2500 |
|
$total = $inc_tax ? $item->get_total() + $item->get_total_tax() : $item->get_total(); |
| 2501 |
|
|
| 2502 |
|
// Check if we need to round. |
| 2503 |
|
$total = $round ? round( $total, wc_get_price_decimals() ) : $total; |
| 2504 |
|
} |
| 2505 |
|
|
| 2506 |
|
return apply_filters( 'woocommerce_order_amount_line_total', $total, $this, $item, $inc_tax, $round ); |
| 2507 |
|
} |
| 2508 |
|
|
| 2509 |
|
/** |
| 2510 |
|
* Get item tax - useful for gateways. |