AbanteCart Community
AbanteCart Development => Customization help => Topic started by: hus2020 on April 21, 2017, 06:38:17 AM
-
I would like to customize the deduction of account balance. By default, account balance is always deducted from the final total; i.e. SubTotal + Taxes + Shipping.
I want the account balance to be deducted from SubTotal only.
I want the calculation to be like this for example:
Sub Total : 100
Account balance : 50 (based on available balance)
Tax : Lets sat 10% VAT at (100-50) which is 10% from 50 = 5
Shipping : Lets take flat shipping of 10.
This way the final total is : 50 + 5 + 10 = 65
Just to share by default, this is how Abantecart applies account balance
Sub total : 100
Taxes : 10% VAT from 100 = 10
Shipping : 10
Account balance : 50 (based on available balance)
This way the final total is : 100+10+10-50 = 70
How can I achieve the calculation I intend to? Please guide.
-
please try to play with calculation order of order total extensions.
I mean setting calc order of "balance" greater than "subtotal" and less than other on page Extensions->Order totals
-
That was the first thing I did. Sadly, that did not help at all. When I tried to find the relevant code, I see that the sort order is hard-coded at order 999. Below is the model file of 'balance.php'
I tried to simply change the sort_order but that just seems to change the display position in order summary i.e. just the display order. The calculation formula still takes account balance after sub total+shipping+taxes.
Please advice how can I come around?
<?php
/*------------------------------------------------------------------------------
$Id$
AbanteCart, Ideal OpenSource Ecommerce Solution
http://www.AbanteCart.com
Copyright © 2011-2016 Belavier Commerce LLC
This source file is subject to Open Software License (OSL 3.0)
License details is bundled with this package in the file LICENSE.txt.
It is also available at this URL:
<http://www.opensource.org/licenses/OSL-3.0>
UPGRADE NOTE:
Do not edit or add to this file if you wish to upgrade AbanteCart to newer
versions in the future. If you wish to customize AbanteCart for your
needs please refer to http://www.AbanteCart.com for more information.
------------------------------------------------------------------------------*/
if (! defined ( 'DIR_CORE' )) {
header ( 'Location: static_pages/' );
}
class ModelTotalBalance extends Model {
public function getTotal(&$total_data, &$total, &$taxes, &$cust_data) {
if ($this->config->get('balance_status')) {
if((float)$cust_data['used_balance']){
$total_data[] = array(
'id' => 'balance',
'title' => $this->language->get('text_balance_checkout'),
'text' => '-'.$this->currency->format($cust_data['used_balance']),
'value' => - $this->session->data['used_balance'],
'sort_order' => 999,
'total_type' => 'balance'
);
$total -= $cust_data['used_balance'];
}
}
}
}