|
@@ 1344-1358 (lines=15) @@
|
| 1341 |
|
* @param bool $round (default: true). |
| 1342 |
|
* @return float |
| 1343 |
|
*/ |
| 1344 |
|
public function get_line_subtotal( $item, $inc_tax = false, $round = true ) { |
| 1345 |
|
$subtotal = 0; |
| 1346 |
|
|
| 1347 |
|
if ( is_callable( array( $item, 'get_subtotal' ) ) ) { |
| 1348 |
|
if ( $inc_tax ) { |
| 1349 |
|
$subtotal = $item->get_subtotal() + $item->get_subtotal_tax(); |
| 1350 |
|
} else { |
| 1351 |
|
$subtotal = $item->get_subtotal(); |
| 1352 |
|
} |
| 1353 |
|
|
| 1354 |
|
$subtotal = $round ? round( $subtotal, wc_get_price_decimals() ) : $subtotal; |
| 1355 |
|
} |
| 1356 |
|
|
| 1357 |
|
return apply_filters( 'woocommerce_order_amount_line_subtotal', $subtotal, $this, $item, $inc_tax, $round ); |
| 1358 |
|
} |
| 1359 |
|
|
| 1360 |
|
/** |
| 1361 |
|
* Calculate item cost - useful for gateways. |
|
@@ 1392-1404 (lines=13) @@
|
| 1389 |
|
* @param bool $round (default: true). |
| 1390 |
|
* @return float |
| 1391 |
|
*/ |
| 1392 |
|
public function get_line_total( $item, $inc_tax = false, $round = true ) { |
| 1393 |
|
$total = 0; |
| 1394 |
|
|
| 1395 |
|
if ( is_callable( array( $item, 'get_total' ) ) ) { |
| 1396 |
|
// Check if we need to add line tax to the line total. |
| 1397 |
|
$total = $inc_tax ? $item->get_total() + $item->get_total_tax() : $item->get_total(); |
| 1398 |
|
|
| 1399 |
|
// Check if we need to round. |
| 1400 |
|
$total = $round ? round( $total, wc_get_price_decimals() ) : $total; |
| 1401 |
|
} |
| 1402 |
|
|
| 1403 |
|
return apply_filters( 'woocommerce_order_amount_line_total', $total, $this, $item, $inc_tax, $round ); |
| 1404 |
|
} |
| 1405 |
|
|
| 1406 |
|
/** |
| 1407 |
|
* Get item tax - useful for gateways. |