I am trying to figure out how to modify this code snippet so I can pull the gstexempt value from the #__kiduka_accounts table, check if it is set to 0 or 1 and apply the tax value accordingly.
$db = JFactory::getDBO();
$query = 'SELECT a.id, a.gstexempt FROM #__users as u
LEFT JOIN #__kiduka_accounts as a ON u.id = a.user_id
WHERE u.gid < 23';
if(JRequest::getInt('membertype', 0) > 0)
{
$query .= ' AND a.membertype = '.JRequest::getInt('membertype', 0);
}
$db->setQuery($query);
$users = $db->loadResultArray();
$query = 'SELECT * FROM #__kiduka_products WHERE id = '.JRequest::getVar('purchaseproduct');
$db->setQuery($query);
$product = $db->loadObject();
$params = JComponentHelper::getParams('com_kiduka');
$tax = $params->get('tax');
$gstexempt = $users->gstexempt;
if ($gstexempt != 1) {
$subtotal = $product->price;
$taxtotal = $subtotal * $tax / 100;
$finaltotal = $taxtotal + $subtotal;
} else {
$subtotal = $product->price;
$taxtotal = "0.00";
$finaltotal = $subtotal;
}
Can anyone share some insight on what I need to change to make this work?
Thank you.
Mike