|
@@ 1291-1305 (lines=15) @@
|
| 1288 |
|
* @param bool $round (default: true). |
| 1289 |
|
* @return float |
| 1290 |
|
*/ |
| 1291 |
|
public function get_item_subtotal( $item, $inc_tax = false, $round = true ) { |
| 1292 |
|
$subtotal = 0; |
| 1293 |
|
|
| 1294 |
|
if ( is_callable( array( $item, 'get_subtotal' ) ) ) { |
| 1295 |
|
if ( $inc_tax ) { |
| 1296 |
|
$subtotal = ( $item->get_subtotal() + $item->get_subtotal_tax() ) / max( 1, $item->get_qty() ); |
| 1297 |
|
} else { |
| 1298 |
|
$subtotal = ( $item->get_subtotal() / max( 1, $item->get_qty() ) ); |
| 1299 |
|
} |
| 1300 |
|
|
| 1301 |
|
$subtotal = $round ? number_format( (float) $subtotal, wc_get_price_decimals(), '.', '' ) : $subtotal; |
| 1302 |
|
} |
| 1303 |
|
|
| 1304 |
|
return apply_filters( 'woocommerce_order_amount_item_subtotal', $subtotal, $this, $item, $inc_tax, $round ); |
| 1305 |
|
} |
| 1306 |
|
|
| 1307 |
|
/** |
| 1308 |
|
* Get line subtotal - this is the cost before discount. |
|
@@ 1339-1353 (lines=15) @@
|
| 1336 |
|
* @param bool $round (default: true). |
| 1337 |
|
* @return float |
| 1338 |
|
*/ |
| 1339 |
|
public function get_item_total( $item, $inc_tax = false, $round = true ) { |
| 1340 |
|
$total = 0; |
| 1341 |
|
|
| 1342 |
|
if ( is_callable( array( $item, 'get_total' ) ) ) { |
| 1343 |
|
if ( $inc_tax ) { |
| 1344 |
|
$total = ( $item->get_total() + $item->get_total_tax() ) / max( 1, $item->get_qty() ); |
| 1345 |
|
} else { |
| 1346 |
|
$total = $item->get_total() / max( 1, $item->get_qty() ); |
| 1347 |
|
} |
| 1348 |
|
|
| 1349 |
|
$total = $round ? round( $total, wc_get_price_decimals() ) : $total; |
| 1350 |
|
} |
| 1351 |
|
|
| 1352 |
|
return apply_filters( 'woocommerce_order_amount_item_total', $total, $this, $item, $inc_tax, $round ); |
| 1353 |
|
} |
| 1354 |
|
|
| 1355 |
|
/** |
| 1356 |
|
* Calculate line total - useful for gateways. |