我试图弄清楚如何修改此代码片段,以便我可以从 #__kiduka_accounts 表中提取 gstexempt 值,检查它是设置为 0 还是 1 并相应地应用税值。
$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;
}
任何人都可以分享一些关于我需要改变什么才能完成这项工作的见解吗?
谢谢你。
麦克风