Code: Select all
$results = $this->model_checkout_extension->getExtensions('total');
foreach ($results as $result) {
$this->load->model('total/' . $result['key']);
$this->{'model_total_' . $result['key']}->getTotal($total_data, $total, $taxes);
}
$sort_order = array();
foreach ($total_data as $key => $value) {
$sort_order[$key] = $value['sort_order'];
}
array_multisort($sort_order, SORT_ASC, $total_data);
So If I add a new total module for military discount, and set the sort order to 2, which is the same as the Low Order Fee module.... It will show the discount in the total, but won't actually take the discount off because the "total" module has already loaded first. (and yes you can trust that I coded it correctly

Code: Select all
$results
: array =
0: array =
extension_id: string = "14"
type: string = "total"
key: string = "coupon"
1: array =
extension_id: string = "22"
type: string = "total"
key: string = "shipping"
2: array =
extension_id: string = "63"
type: string = "total"
key: string = "low_order_fee"
3: array =
extension_id: string = "57"
type: string = "total"
key: string = "sub_total"
4: array =
extension_id: string = "58"
type: string = "total"
key: string = "tax"
5: array =
extension_id: string = "59"
type: string = "total"
key: string = "total"
6: array =
extension_id: string = "102"
type: string = "total"
key: string = "handling"
7: array =
extension_id: string = "107"
type: string = "total"
key: string = "military_discount"
You will see this is already a problem with the new "Handling" total extension, as it also loads after total.
There needs to be a sort on these results before doing the getTotal on each of them so that "total" can always be last.