radicaledward
03-15-2005, 01:28 AM
One of the big issues that I have had with the shop is that it didn't check secondary usergroups for discounts. Since members that donate to the site get a discount this is necessary on our board, and it has been necessary for me to write a fix for this issue. So to solve this problem I have written the following code - feel free to use it as you see fit. :)
In /includes/functions_uttstore.php:
Find in function calculate_discounted_price:
// Generate Usergroup Discount
if ($permissions['uttstore_discount'] != "0") {
$adiscountd = ($permissions['uttstore_discount'] / 100);
$adiscount = ($adiscountd * $price);
(isset($discount) ? $discount = ($discount - $adiscount) : $discount = ($price - $adiscount));
}
Replace with:
//------------------------------------------------------------------------
// Generate Discounts
//------------------------------------------------------------------------
// Get the list of groups and discounts
global $DB_site;
$groupdiscounts = $DB_site->query("SELECT usergroupid, uttstore_discount FROM usergroup WHERE uttstore_discount != '0'");
// Loop through the groups
if (!empty($groupdiscounts)) {
while ($groupdiscount = $DB_site->fetch_array($groupdiscounts)) {
// Check to see if the user is a member, if so then add the discount
if (is_member_of($bbuserinfo, $groupdiscount['usergroupid'])) {
$adiscountd += ($groupdiscount['uttstore_discount'] / 100);
}
}
}
// Determine the price
$adiscount = ($adiscountd * $price);
(isset($discount) ? $discount = ($discount - $adiscount) : $discount = ($price - $adiscount));
//------------------------------------------------------------------------
Find in function calculate_discount_percent:
// Generate Usergroup Discount
if ($permissions['uttstore_discount'] != "0") {
$adiscountd = ($permissions['uttstore_discount']);
(isset($discount) ? $discount = ($discount + $adiscountd) : $discount = ($price + $adiscountd));
}
Replace with:
//------------------------------------------------------------------------
// Generate Discount Percentage
//------------------------------------------------------------------------
// Get the list of groups and discounts
global $DB_site;
$groupdiscounts = $DB_site->query("SELECT usergroupid, uttstore_discount FROM usergroup WHERE uttstore_discount != '0'");
// Loop through the groups
if (!empty($groupdiscounts)) {
while ($groupdiscount = $DB_site->fetch_array($groupdiscounts)) {
// Check to see if the user is a member, if so then add the discount
if (is_member_of($bbuserinfo, $groupdiscount['usergroupid'])) {
$adiscountd += ($groupdiscount['uttstore_discount']);
}
}
}
// Determine the amount
(isset($discount) ? $discount = ($discount + $adiscountd) : $discount = ($price + $adiscountd));
//------------------------------------------------------------------------
In /includes/functions_uttstore.php:
Find in function calculate_discounted_price:
// Generate Usergroup Discount
if ($permissions['uttstore_discount'] != "0") {
$adiscountd = ($permissions['uttstore_discount'] / 100);
$adiscount = ($adiscountd * $price);
(isset($discount) ? $discount = ($discount - $adiscount) : $discount = ($price - $adiscount));
}
Replace with:
//------------------------------------------------------------------------
// Generate Discounts
//------------------------------------------------------------------------
// Get the list of groups and discounts
global $DB_site;
$groupdiscounts = $DB_site->query("SELECT usergroupid, uttstore_discount FROM usergroup WHERE uttstore_discount != '0'");
// Loop through the groups
if (!empty($groupdiscounts)) {
while ($groupdiscount = $DB_site->fetch_array($groupdiscounts)) {
// Check to see if the user is a member, if so then add the discount
if (is_member_of($bbuserinfo, $groupdiscount['usergroupid'])) {
$adiscountd += ($groupdiscount['uttstore_discount'] / 100);
}
}
}
// Determine the price
$adiscount = ($adiscountd * $price);
(isset($discount) ? $discount = ($discount - $adiscount) : $discount = ($price - $adiscount));
//------------------------------------------------------------------------
Find in function calculate_discount_percent:
// Generate Usergroup Discount
if ($permissions['uttstore_discount'] != "0") {
$adiscountd = ($permissions['uttstore_discount']);
(isset($discount) ? $discount = ($discount + $adiscountd) : $discount = ($price + $adiscountd));
}
Replace with:
//------------------------------------------------------------------------
// Generate Discount Percentage
//------------------------------------------------------------------------
// Get the list of groups and discounts
global $DB_site;
$groupdiscounts = $DB_site->query("SELECT usergroupid, uttstore_discount FROM usergroup WHERE uttstore_discount != '0'");
// Loop through the groups
if (!empty($groupdiscounts)) {
while ($groupdiscount = $DB_site->fetch_array($groupdiscounts)) {
// Check to see if the user is a member, if so then add the discount
if (is_member_of($bbuserinfo, $groupdiscount['usergroupid'])) {
$adiscountd += ($groupdiscount['uttstore_discount']);
}
}
}
// Determine the amount
(isset($discount) ? $discount = ($discount + $adiscountd) : $discount = ($price + $adiscountd));
//------------------------------------------------------------------------