Hi, there appears to be a bug regarding the "total" order extension.
If the "sub-total" extension is disable then the total order value is 0 (zero). If the sub-total order has a greater sort-order than the total extension, then the total is 0 (zero), but sub-total is correct. I have tried this with the handling fee installed and the problem remains.
I ran the following tests which replicate the problem. Please note the first test is a base test:
Base Text - Product £100 (no tax):
enabled extension: sub-total (sort-order 1) | total (sort-order 2)
expected results: 100.00 | 100.00
actual results: 100.00 | 100.00
Test 1 Product £100 (no tax):
enabled extension: total (sort-order 1) | sub-total (sort-order 2)
expected results: 100.00 | 100.00
actual results: 0.00 | 100.00
Test 2 Product £100 (no tax):
enabled extension: total (sort-order 1)
expected results: 100.00
actual results: 0.00
I wish to enable the total extension and the handling fee extension only. Thanks in advance for any information regarding this issue.
If the "sub-total" extension is disable then the total order value is 0 (zero). If the sub-total order has a greater sort-order than the total extension, then the total is 0 (zero), but sub-total is correct. I have tried this with the handling fee installed and the problem remains.
I ran the following tests which replicate the problem. Please note the first test is a base test:
Base Text - Product £100 (no tax):
enabled extension: sub-total (sort-order 1) | total (sort-order 2)
expected results: 100.00 | 100.00
actual results: 100.00 | 100.00
Test 1 Product £100 (no tax):
enabled extension: total (sort-order 1) | sub-total (sort-order 2)
expected results: 100.00 | 100.00
actual results: 0.00 | 100.00
Test 2 Product £100 (no tax):
enabled extension: total (sort-order 1)
expected results: 100.00
actual results: 0.00
I wish to enable the total extension and the handling fee extension only. Thanks in advance for any information regarding this issue.
Having taken a look at some of the underlying code (namely: catalog\model\total\total.php) the problem appears quite deep. Currently (version 1.48) the total extension uses the $total parameter to set it's value:
A possible solution is to calculate the total independently (removing it from the order-total extensions). This, I think, is necessary if this value is used in the payment modules. This total would need to utilise the cart values if either the sub-total and tax are disabled.
As I am fairly new to opencart I would appreciate any feedback, thanks.
Code: Select all
$total_data[] = array(
'title' => $this->language->get('text_total'),
'text' => $this->currency->format(max(0,$total)),
'value' => max(0,$total),
'sort_order' => $this->config->get('total_sort_order')
);
As I am fairly new to opencart I would appreciate any feedback, thanks.
This was a feature added in 1.4.8 because it was possible to have
Subtotal: 100
Discount: -200
Total: -100
So I made it 0 if negative.
You are setting sort order of Total before Subtotal to get your results, which doesn't really make sense. Subtotal is technically required and needs to be first or second since it contains the product price information
Subtotal: 100
Discount: -200
Total: -100
So I made it 0 if negative.
You are setting sort order of Total before Subtotal to get your results, which doesn't really make sense. Subtotal is technically required and needs to be first or second since it contains the product price information
Thanks for the response.
I take you point regarding the negative values. However as the total extension, from the $total parameter, relies on all other order extensions being calculated first, then allowing an administrator to set the execution order (via the sort-order) is opening the platform up to problems. This is equally the case when allowing administrators to disable order extensions that are technically required (sub-total, total).
As a work around, I will reset the sort order to the default values and re-order them in my views.
Again any feedback is appreciated.
I take you point regarding the negative values. However as the total extension, from the $total parameter, relies on all other order extensions being calculated first, then allowing an administrator to set the execution order (via the sort-order) is opening the platform up to problems. This is equally the case when allowing administrators to disable order extensions that are technically required (sub-total, total).
As a work around, I will reset the sort order to the default values and re-order them in my views.
Again any feedback is appreciated.
This is a bug. Here is an easy solution:If the "sub-total" extension is disable then the total order value is 0 (zero).
SubTotal should be taken into account even if "sub_total_status" is disabled (which means no shown).
So, the code "$total += $this->cart->getSubTotal();" should be out of IF condition.
Here is the final version of \catalog\model\total\sub_total.php
Code: Select all
<?php
class ModelTotalSubTotal extends Model {
public function getTotal(&$total_data, &$total, &$taxes) {
if ($this->config->get('sub_total_status')) {
$this->load->language('total/sub_total');
$total_data[] = array(
'title' => $this->language->get('text_sub_total'),
'text' => $this->currency->format($this->cart->getSubTotal()),
'value' => $this->cart->getSubTotal(),
'sort_order' => $this->config->get('sub_total_sort_order')
);
}
$total += $this->cart->getSubTotal();
}
}
?>
It's unduly.I guess technically we should just remove the status and sort options for subtotal and total

\catalog\model\total\sub_total.php
Code: Select all
<?php
class ModelTotalSubTotal extends Model {
public function getTotal(&$total_data, &$total, &$taxes) {
if ($this->config->get('sub_total_status')) {
$this->load->language('total/sub_total');
$total_data[] = array(
'title' => $this->language->get('text_sub_total'),
'text' => $this->currency->format($this->cart->getSubTotal()),
'value' => $this->cart->getSubTotal(),
'sort_order' => $this->config->get('sub_total_sort_order')
);
}
}
}
?>
Code: Select all
<?php
class ModelTotalTotal extends Model {
public function getTotal(&$total_data, &$total, &$taxes) {
if ($this->config->get('total_status')) {
$this->load->language('total/total');
$this->load->model('localisation/currency');
$total += $this->cart->getSubTotal();
$total_data[] = array(
'title' => $this->language->get('text_total'),
'text' => $this->currency->format(max(0,$total)),
'value' => max(0,$total),
'sort_order' => $this->config->get('total_sort_order')
);
}
}
}
?>
Who is online
Users browsing this forum: No registered users and 1 guest