Version: , by radicaledward
Developer Last Online: Dec 2007
Version: Unknown
Rating:
Released: 03-15-2005
Last Update: Never
Installs: 0
No support by the author.
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.
//------------------------------------------------------------------------
// 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));
//------------------------------------------------------------------------
//------------------------------------------------------------------------
// 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));
//------------------------------------------------------------------------
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
I thought of doing that, but our site is a bit unique in that we make extensive use of secondary groups for members. For example, my account has the following group memberships:
Administrators: 0% discount
Senior Members (been on the site for a long time): 5% discount
Friends of ACF (people that donated money to the site): 10% discount
Loyal member discount (registered on site for 365 days): 5% discount
Since the members were complaining about not getting all of the discounts this was judged to be the best course of action, as opposed to telling them that the highest discount is the total discount.