|
@@ 1267-1281 (lines=15) @@
|
| 1264 |
|
* @param bool $round (default: true). |
| 1265 |
|
* @return float |
| 1266 |
|
*/ |
| 1267 |
|
public function get_item_subtotal( $item, $inc_tax = false, $round = true ) { |
| 1268 |
|
$subtotal = 0; |
| 1269 |
|
|
| 1270 |
|
if ( is_callable( array( $item, 'get_subtotal' ) ) ) { |
| 1271 |
|
if ( $inc_tax ) { |
| 1272 |
|
$subtotal = ( $item->get_subtotal() + $item->get_subtotal_tax() ) / max( 1, $item->get_quantity() ); |
| 1273 |
|
} else { |
| 1274 |
|
$subtotal = ( $item->get_subtotal() / max( 1, $item->get_quantity() ) ); |
| 1275 |
|
} |
| 1276 |
|
|
| 1277 |
|
$subtotal = $round ? number_format( (float) $subtotal, wc_get_price_decimals(), '.', '' ) : $subtotal; |
| 1278 |
|
} |
| 1279 |
|
|
| 1280 |
|
return apply_filters( 'woocommerce_order_amount_item_subtotal', $subtotal, $this, $item, $inc_tax, $round ); |
| 1281 |
|
} |
| 1282 |
|
|
| 1283 |
|
/** |
| 1284 |
|
* Get line subtotal - this is the cost before discount. |
|
@@ 1315-1329 (lines=15) @@
|
| 1312 |
|
* @param bool $round (default: true). |
| 1313 |
|
* @return float |
| 1314 |
|
*/ |
| 1315 |
|
public function get_item_total( $item, $inc_tax = false, $round = true ) { |
| 1316 |
|
$total = 0; |
| 1317 |
|
|
| 1318 |
|
if ( is_callable( array( $item, 'get_total' ) ) ) { |
| 1319 |
|
if ( $inc_tax ) { |
| 1320 |
|
$total = ( $item->get_total() + $item->get_total_tax() ) / max( 1, $item->get_quantity() ); |
| 1321 |
|
} else { |
| 1322 |
|
$total = $item->get_total() / max( 1, $item->get_quantity() ); |
| 1323 |
|
} |
| 1324 |
|
|
| 1325 |
|
$total = $round ? round( $total, wc_get_price_decimals() ) : $total; |
| 1326 |
|
} |
| 1327 |
|
|
| 1328 |
|
return apply_filters( 'woocommerce_order_amount_item_total', $total, $this, $item, $inc_tax, $round ); |
| 1329 |
|
} |
| 1330 |
|
|
| 1331 |
|
/** |
| 1332 |
|
* Calculate line total - useful for gateways. |