|
@@ 1402-1416 (lines=15) @@
|
| 1399 |
|
* @param bool $round (default: true). |
| 1400 |
|
* @return float |
| 1401 |
|
*/ |
| 1402 |
|
public function get_item_subtotal( $item, $inc_tax = false, $round = true ) { |
| 1403 |
|
$subtotal = 0; |
| 1404 |
|
|
| 1405 |
|
if ( is_callable( array( $item, 'get_subtotal' ) ) ) { |
| 1406 |
|
if ( $inc_tax ) { |
| 1407 |
|
$subtotal = ( $item->get_subtotal() + $item->get_subtotal_tax() ) / max( 1, $item->get_qty() ); |
| 1408 |
|
} else { |
| 1409 |
|
$subtotal = ( $item->get_subtotal() / max( 1, $item->get_qty() ) ); |
| 1410 |
|
} |
| 1411 |
|
|
| 1412 |
|
$subtotal = $round ? number_format( (float) $subtotal, wc_get_price_decimals(), '.', '' ) : $subtotal; |
| 1413 |
|
} |
| 1414 |
|
|
| 1415 |
|
return apply_filters( 'woocommerce_order_amount_item_subtotal', $subtotal, $this, $item, $inc_tax, $round ); |
| 1416 |
|
} |
| 1417 |
|
|
| 1418 |
|
/** |
| 1419 |
|
* Get line subtotal - this is the cost before discount. |
|
@@ 1450-1464 (lines=15) @@
|
| 1447 |
|
* @param bool $round (default: true). |
| 1448 |
|
* @return float |
| 1449 |
|
*/ |
| 1450 |
|
public function get_item_total( $item, $inc_tax = false, $round = true ) { |
| 1451 |
|
$total = 0; |
| 1452 |
|
|
| 1453 |
|
if ( is_callable( array( $item, 'get_total' ) ) ) { |
| 1454 |
|
if ( $inc_tax ) { |
| 1455 |
|
$total = ( $item->get_total() + $item->get_total_tax() ) / max( 1, $item->get_qty() ); |
| 1456 |
|
} else { |
| 1457 |
|
$total = $item->get_total() / max( 1, $item->get_qty() ); |
| 1458 |
|
} |
| 1459 |
|
|
| 1460 |
|
$total = $round ? round( $total, wc_get_price_decimals() ) : $total; |
| 1461 |
|
} |
| 1462 |
|
|
| 1463 |
|
return apply_filters( 'woocommerce_order_amount_item_total', $total, $this, $item, $inc_tax, $round ); |
| 1464 |
|
} |
| 1465 |
|
|
| 1466 |
|
/** |
| 1467 |
|
* Calculate line total - useful for gateways. |