|
@@ 2397-2411 (lines=15) @@
|
| 2394 |
|
* @param bool $round (default: true). |
| 2395 |
|
* @return float |
| 2396 |
|
*/ |
| 2397 |
|
public function get_item_subtotal( $item, $inc_tax = false, $round = true ) { |
| 2398 |
|
$subtotal = 0; |
| 2399 |
|
|
| 2400 |
|
if ( is_callable( array( $item, 'get_subtotal' ) ) ) { |
| 2401 |
|
if ( $inc_tax ) { |
| 2402 |
|
$subtotal = ( $item->get_subtotal() + $item->get_subtotal_tax() ) / max( 1, $item->get_qty() ); |
| 2403 |
|
} else { |
| 2404 |
|
$subtotal = ( $item->get_subtotal() / max( 1, $item->get_qty() ) ); |
| 2405 |
|
} |
| 2406 |
|
|
| 2407 |
|
$subtotal = $round ? number_format( (float) $subtotal, wc_get_price_decimals(), '.', '' ) : $subtotal; |
| 2408 |
|
} |
| 2409 |
|
|
| 2410 |
|
return apply_filters( 'woocommerce_order_amount_item_subtotal', $subtotal, $this, $item, $inc_tax, $round ); |
| 2411 |
|
} |
| 2412 |
|
|
| 2413 |
|
/** |
| 2414 |
|
* Get line subtotal - this is the cost before discount. |
|
@@ 2445-2459 (lines=15) @@
|
| 2442 |
|
* @param bool $round (default: true). |
| 2443 |
|
* @return float |
| 2444 |
|
*/ |
| 2445 |
|
public function get_item_total( $item, $inc_tax = false, $round = true ) { |
| 2446 |
|
$total = 0; |
| 2447 |
|
|
| 2448 |
|
if ( is_callable( array( $item, 'get_total' ) ) ) { |
| 2449 |
|
if ( $inc_tax ) { |
| 2450 |
|
$total = ( $item->get_total() + $item->get_total_tax() ) / max( 1, $item->get_qty() ); |
| 2451 |
|
} else { |
| 2452 |
|
$total = $item->get_total() / max( 1, $item->get_qty() ); |
| 2453 |
|
} |
| 2454 |
|
|
| 2455 |
|
$total = $round ? round( $total, wc_get_price_decimals() ) : $total; |
| 2456 |
|
} |
| 2457 |
|
|
| 2458 |
|
return apply_filters( 'woocommerce_order_amount_item_total', $total, $this, $item, $inc_tax, $round ); |
| 2459 |
|
} |
| 2460 |
|
|
| 2461 |
|
/** |
| 2462 |
|
* Calculate line total - useful for gateways. |