|
@@ 1430-1444 (lines=15) @@
|
| 1427 |
|
* @param bool $round (default: true). |
| 1428 |
|
* @return float |
| 1429 |
|
*/ |
| 1430 |
|
public function get_item_subtotal( $item, $inc_tax = false, $round = true ) { |
| 1431 |
|
$subtotal = 0; |
| 1432 |
|
|
| 1433 |
|
if ( is_callable( array( $item, 'get_subtotal' ) ) ) { |
| 1434 |
|
if ( $inc_tax ) { |
| 1435 |
|
$subtotal = ( $item->get_subtotal() + $item->get_subtotal_tax() ) / max( 1, $item->get_qty() ); |
| 1436 |
|
} else { |
| 1437 |
|
$subtotal = ( $item->get_subtotal() / max( 1, $item->get_qty() ) ); |
| 1438 |
|
} |
| 1439 |
|
|
| 1440 |
|
$subtotal = $round ? number_format( (float) $subtotal, wc_get_price_decimals(), '.', '' ) : $subtotal; |
| 1441 |
|
} |
| 1442 |
|
|
| 1443 |
|
return apply_filters( 'woocommerce_order_amount_item_subtotal', $subtotal, $this, $item, $inc_tax, $round ); |
| 1444 |
|
} |
| 1445 |
|
|
| 1446 |
|
/** |
| 1447 |
|
* Get line subtotal - this is the cost before discount. |
|
@@ 1478-1492 (lines=15) @@
|
| 1475 |
|
* @param bool $round (default: true). |
| 1476 |
|
* @return float |
| 1477 |
|
*/ |
| 1478 |
|
public function get_item_total( $item, $inc_tax = false, $round = true ) { |
| 1479 |
|
$total = 0; |
| 1480 |
|
|
| 1481 |
|
if ( is_callable( array( $item, 'get_total' ) ) ) { |
| 1482 |
|
if ( $inc_tax ) { |
| 1483 |
|
$total = ( $item->get_total() + $item->get_total_tax() ) / max( 1, $item->get_qty() ); |
| 1484 |
|
} else { |
| 1485 |
|
$total = $item->get_total() / max( 1, $item->get_qty() ); |
| 1486 |
|
} |
| 1487 |
|
|
| 1488 |
|
$total = $round ? round( $total, wc_get_price_decimals() ) : $total; |
| 1489 |
|
} |
| 1490 |
|
|
| 1491 |
|
return apply_filters( 'woocommerce_order_amount_item_total', $total, $this, $item, $inc_tax, $round ); |
| 1492 |
|
} |
| 1493 |
|
|
| 1494 |
|
/** |
| 1495 |
|
* Calculate line total - useful for gateways. |