by mona wrote: ↑Sat Jan 16, 2021 1:18 am
@OSWorX -

I can pronounce it correctly !
yes - thank you - it has to go through sub_total.php, but that is insane - and very dangerous
There appears to be no valid reason for the ability to disable and not to calculate correctly - Is there a reason?
Don't worry about - important you find me and my Website if you need it
The reason why it has to go through the file, is -
the sums (subtotal and total) are calculated inside.
Subtotal is in 99% of all shops the first line in the cart - displaying the net value of the whole cart.
This is done inside the
cart controller (system file) by calling the
function getSubtotal():
Code: Select all
public function getSubTotal() {
$total = 0;
foreach ($this->getProducts() as $product) {
$total += $product['total'];
}
return $total;
}
As can be seen here, it loops through all products are in the cart and summarize the net value ($total) which is then returned (into the sub_total controller):
Code: Select all
$sub_total = $this->cart->getSubTotal();
After getting the subtotal in the subtotal controller, a check is made if there are any voucher values to add.
Then, the subtotal controller builds the output:
Code: Select all
$total['totals'][] = array(
'code' => 'sub_total',
'title' => $this->language->get('text_sub_total'),
'value' => $sub_total,
'sort_order' => $this->config->get('sub_total_sort_order')
);
which we do not need here in this case (or this request).
After that, the last line is:
which adds the former build subtotal to the total value (
$total['total']) which itself is available later in some controllers (e.g. payment_method).
And this is the reason why this subtotal function (available through the menu
Extensions > Extensions >Order Totals >> Sub-Total) shall
NOT be disabled.
Because if, the whole further calculation is not correct.
Hope I could explain it good enough ..
What could be done to extend the core code by adding a setting to "hide" the output.
A "feature request" - maybe usefull for users and cases like this here: simply define if output yes or no inside the order totals definitions.
But calculation is done in every case.
And yes, simply disabling this order total module/extension can lead to some very unwanted results ..