Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > Premium Archives > uCash & uShop
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Discount calculation improvements Details »»
Discount calculation improvements
Version: , by radicaledward radicaledward is offline
Developer Last Online: Dec 2007 Show Printable Version Email this Page

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.

In /includes/functions_uttstore.php:

Find in function calculate_discounted_price:
PHP Code:
// 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:
PHP Code:
//------------------------------------------------------------------------
// 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:
PHP Code:
// Generate Usergroup Discount
if ($permissions['uttstore_discount'] != "0") {
    
$adiscountd = ($permissions['uttstore_discount']);
    (isset(
$discount) ? $discount = ($discount $adiscountd) : $discount = ($price $adiscountd));

Replace with:
PHP Code:
    //------------------------------------------------------------------------
// 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.

Comments
  #2  
Old 03-15-2005, 03:14 AM
Link14716's Avatar
Link14716 Link14716 is offline
 
Join Date: Jun 2002
Location: Georgia, USA
Posts: 2,519
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This might be a better solution. Instead of all that, in includes/init.php, find:
PHP Code:
    'pmsendmax'             => 0
Add under:
PHP Code:
    'uttstore_discount'     => 0
It won't loop through each usergroup and add the discounts, but it will take the highest value instead.
Reply With Quote
  #3  
Old 03-15-2005, 04:29 AM
radicaledward's Avatar
radicaledward radicaledward is offline
 
Join Date: Jul 2004
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:46 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06144 seconds
  • Memory Usage 2,235KB
  • Queries Executed 16 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (2)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete