This won't work if the Total fields 'Read Only' checkbox is ticked:
Code: Select all
function tablename_before_update(&$data, $memberInfo, &$args){
// calculate total after applying discount
$data['total'] = $data['subtotal'] * (1 - $data['discount'] / 100);
// calculate total after applying sales tax
$data['total'] = $data['total'] * (1 + $data['sales_tax'] / 100);
return TRUE;
}