Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2008
    Posts
    45
    Plugin Contributions
    0

    Default Discount by user

    Hi,

    I need to have 3 different types of users.

    1 - users who get a fixed % discount off everything. I am planning on using group discounts to do this

    2 - users who get a % discount depending on how much they spend. I have installed the price sensitive discount module for this

    3 - users who don't get any discount. I have set up a group with 0% discount for this

    The bit I am stuck on is turning off the price sensitive discount for users who belong to groups. Could someone tell me which function in the price sensitive discount module actually calculates the discount. I am planning on putting an if statement around it to just set the discount to 0 if the user is part of a group, unless anyone can suggest a better way!

    Thanks in advance

    Rachael

  2. #2
    Join Date
    Jan 2008
    Posts
    45
    Plugin Contributions
    0

    Default Re: Discount by user

    ok I have figured it out so here's how i did it incase anyone else is having similar problems

    To apply the price sensitive discount ONLY to members who are not in groups you need to edit includes/modules/ot_lev_discount.php. go to the function calculate_credit($amount) and replace with the following

    function calculate_credit($amount) {
    global $order, $db; // add $db for query

    // see if current customer belongs to a group
    $group_query = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");


    // if they don't calculate the discount
    if ($group_query->fields['customers_group_pricing'] == '0') {

    $od_amount=0;
    $table_cost = split("[:,]" , MODULE_LEV_DISCOUNT_TABLE);
    for ($i = 0; $i < count($table_cost); $i+=2) {
    if ($amount >= $table_cost[$i]) {
    $od_pc = $table_cost[$i+1];
    }
    }
    // Calculate tax reduction if necessary
    if($this->calculate_tax == 'true') {
    // Calculate main tax reduction
    $tod_amount = round($order->info['tax']*10)/10*$od_pc/100;
    $order->info['tax'] = $order->info['tax'] - $tod_amount;
    // Calculate tax group deductions
    reset($order->info['tax_groups']);
    while (list($key, $value) = each($order->info['tax_groups'])) {
    $god_amount = round($value*10)/10*$od_pc/100;
    $order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount;
    }
    }
    $od_amount = round($amount*10)/10*$od_pc/100;
    // $od_amount = $od_amount + $tod_amount;
    // maniac101 above line was adding tax back into discount incorrectly for me


    } // else if they do belong to a group set discount = 0
    else {
    $od_amount = 0;
    }

    return $od_amount;
    }



    the same method can be used for quantity discounts too. This probably isn't the neatest/best solution but it works fine for me!

 

 

Similar Threads

  1. Set max discount for Group Discount + Discount + etc.
    By KEnik in forum Setting Up Specials and SaleMaker
    Replies: 0
    Last Post: 16 Jun 2010, 05:39 PM
  2. Discount based on user and product
    By emma1 in forum General Questions
    Replies: 0
    Last Post: 18 Feb 2008, 08:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg