|
@@ 1376-1390 (lines=15) @@
|
| 1373 |
|
* @param bool $round (default: true). |
| 1374 |
|
* @return float |
| 1375 |
|
*/ |
| 1376 |
|
public function get_item_subtotal( $item, $inc_tax = false, $round = true ) { |
| 1377 |
|
$subtotal = 0; |
| 1378 |
|
|
| 1379 |
|
if ( is_callable( array( $item, 'get_subtotal' ) ) ) { |
| 1380 |
|
if ( $inc_tax ) { |
| 1381 |
|
$subtotal = ( $item->get_subtotal() + $item->get_subtotal_tax() ) / max( 1, $item->get_quantity() ); |
| 1382 |
|
} else { |
| 1383 |
|
$subtotal = ( $item->get_subtotal() / max( 1, $item->get_quantity() ) ); |
| 1384 |
|
} |
| 1385 |
|
|
| 1386 |
|
$subtotal = $round ? number_format( (float) $subtotal, wc_get_price_decimals(), '.', '' ) : $subtotal; |
| 1387 |
|
} |
| 1388 |
|
|
| 1389 |
|
return apply_filters( 'woocommerce_order_amount_item_subtotal', $subtotal, $this, $item, $inc_tax, $round ); |
| 1390 |
|
} |
| 1391 |
|
|
| 1392 |
|
/** |
| 1393 |
|
* Get line subtotal - this is the cost before discount. |
|
@@ 1424-1438 (lines=15) @@
|
| 1421 |
|
* @param bool $round (default: true). |
| 1422 |
|
* @return float |
| 1423 |
|
*/ |
| 1424 |
|
public function get_item_total( $item, $inc_tax = false, $round = true ) { |
| 1425 |
|
$total = 0; |
| 1426 |
|
|
| 1427 |
|
if ( is_callable( array( $item, 'get_total' ) ) ) { |
| 1428 |
|
if ( $inc_tax ) { |
| 1429 |
|
$total = ( $item->get_total() + $item->get_total_tax() ) / max( 1, $item->get_quantity() ); |
| 1430 |
|
} else { |
| 1431 |
|
$total = $item->get_total() / max( 1, $item->get_quantity() ); |
| 1432 |
|
} |
| 1433 |
|
|
| 1434 |
|
$total = $round ? round( $total, wc_get_price_decimals() ) : $total; |
| 1435 |
|
} |
| 1436 |
|
|
| 1437 |
|
return apply_filters( 'woocommerce_order_amount_item_total', $total, $this, $item, $inc_tax, $round ); |
| 1438 |
|
} |
| 1439 |
|
|
| 1440 |
|
/** |
| 1441 |
|
* Calculate line total - useful for gateways. |