Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16
  1. #11
    Join Date
    Sep 2010
    Posts
    612
    Plugin Contributions
    0

    Default Re: Percentage discount based on order total?

    Anyone else wanna take a look at this? I know the thread is uber confusing...please let me know if you need further clarification. Thank you.

  2. #12
    Join Date
    Sep 2010
    Posts
    612
    Plugin Contributions
    0

    Default Re: Percentage discount based on order total?

    Here are the two mods I have:

    PRICE SENSITIVE DISCOUNT
    PHP Code:
    <?php
    /*

    >>> Rabatt ab xxx Bestellwert 1.0
    Modifiziert von Maleborg für Zencart

    Weitere Credits
    <<<<<<< ot_lev_discount.php
      $Id: ot_lev_discount.php,v 1.0 2002/04/08 01:13:43 hpdl Exp $
    =======
      $Id: ot_lev_discount.php,v 1.3 2002/09/04 22:49:11 wilt Exp $
      $Id: ot_lev_discount.php,v 2.4 2006/02/28 12:10:01 maniac101 Exp $
    modified to calc discount correctly when tax is included in discount
    >>>>>>> 2.4

      osCommerce, Open Source E-Commerce Solutions
      http://www.oscommerce.com

      Copyright (c) 2002 osCommerce

      Released under the GNU General Public License
    */

      
    class ot_lev_discount {
        var 
    $title$output;

        function 
    ot_lev_discount() {
          
    $this->code 'ot_lev_discount';
          
    $this->title MODULE_LEV_DISCOUNT_TITLE;
          
    $this->description MODULE_LEV_DISCOUNT_DESCRIPTION;
          
    $this->enabled MODULE_LEV_DISCOUNT_STATUS;
          
    $this->sort_order MODULE_LEV_DISCOUNT_SORT_ORDER;
          
    $this->include_shipping MODULE_LEV_DISCOUNT_INC_SHIPPING;
          
    $this->include_tax MODULE_LEV_DISCOUNT_INC_TAX;
          
    $this->calculate_tax MODULE_LEV_DISCOUNT_CALC_TAX;
          
    $this->table MODULE_LEV_DISCOUNT_TABLE;
    //      $this->credit_class = true;
          
    $this->output = array();
        }

        function 
    process() {
          global 
    $order$ot_subtotal$currencies$db;
          
    $od_amount $this->calculate_credit($this->get_order_total());
          if (
    $od_amount>0) {
          
    $this->deduction $od_amount;
          
    $this->output[] = array('title' => $this->title ':',
                                  
    'text' => '-' $currencies->format($od_amount),
                                  
    'value' => $od_amount);
        
    $order->info['total'] = $order->info['total'] - $od_amount;
        if (
    $this->sort_order $ot_subtotal->sort_order) {
          
    $order->info['subtotal'] = $order->info['subtotal'] - $od_amount;
        }
    }
        }
         
       
      function 
    calculate_credit($amount) {
        global 
    $order;
        
    $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
        
    return $od_amount;
      }


      function 
    get_order_total() {
        global  
    $order$cart$db;
        
    $order_total $order->info['total'];
    // Check if gift voucher is in cart and adjust total
    //    $products = $cart -> get_products();
        
    for ($i=0$i<sizeof($products); $i++) {
          
    $t_prid zen_get_prid($products[$i]['id']);
          
    $gv_query $db->Execute("select products_price, products_tax_class_id, products_model from " TABLE_PRODUCTS " where products_id = '" $t_prid "'");
          
    //$gv_result = zen_db_fetch_array($gv_query);
          
    if (ereg('^GIFT'addslashes($gv_result['products_model']))) { 
            
    $qty $cart->get_quantity($t_prid);
            
    $products_tax zen_get_tax_rate($gv_result['products_tax_class_id']);
            if (
    $this->include_tax =='false') {
               
    $gv_amount $gv_result['products_price'] * $qty;
            } else {
              
    $gv_amount = ($gv_result['products_price'] + zen_calculate_tax($gv_result['products_price'],$products_tax)) * $qty;
            }
            
    $order_total=$order_total $gv_amount;
          }
        }
        if (
    $this->include_tax == 'false'$order_total=$order_total-$order->info['tax'];
        if (
    $this->include_shipping == 'false'$order_total=$order_total-$order->info['shipping_cost'];
        return 
    $order_total;
      }   
        
        
        
        function 
    check() {
          global 
    $db;
          if (!isset(
    $this->check)) {
            
    $check_query $db->Execute("select configuration_value from " TABLE_CONFIGURATION " where configuration_key = 'MODULE_LEV_DISCOUNT_STATUS'");
            
    $this->check $check_query->RecordCount();
          }

          return 
    $this->check;
        }

        function 
    keys() {
          return array(
    'MODULE_LEV_DISCOUNT_STATUS''MODULE_LEV_DISCOUNT_SORT_ORDER','MODULE_LEV_DISCOUNT_TABLE''MODULE_LEV_DISCOUNT_INC_SHIPPING''MODULE_LEV_DISCOUNT_INC_TAX','MODULE_LEV_DISCOUNT_CALC_TAX');
        }

        function 
    install() {
          global 
    $db;
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Display Total', 'MODULE_LEV_DISCOUNT_STATUS', 'true', 'Do you want to enable the Order Discount?', '6', '1','zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_LEV_DISCOUNT_SORT_ORDER', '50', 'Sort order of display.', '6', '2', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Include Shipping', 'MODULE_LEV_DISCOUNT_INC_SHIPPING', 'false', 'Include Shipping in calculation', '6', '3', 'zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Include Tax', 'MODULE_LEV_DISCOUNT_INC_TAX', 'true', 'Include Tax in calculation.', '6', '4','zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Calculate Tax', 'MODULE_LEV_DISCOUNT_CALC_TAX', 'true', 'Re-calculate Tax on discounted amount.', '6', '5','zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Discount Percentage', 'MODULE_LEV_DISCOUNT_TABLE', '100:7.5,250:10,500:12.5,1000:15', 'Set the price breaks and discount percentages', '6', '6', now())");
        }

        function 
    remove() {
          
    $keys '';
          
    $keys_array $this->keys();
          for (
    $i=0$i<sizeof($keys_array); $i++) {
            
    $keys .= "'" $keys_array[$i] . "',";
          }
          
    $keys substr($keys0, -1);

          global 
    $db;
          
    $db->Execute("delete from " TABLE_CONFIGURATION " where configuration_key in (" $keys ")");
        }
      }
    ?>
    PAYMENT MODULE FEE/DISCOUNT

    PHP Code:
    <?php
    /**
     * ot_total order-total module
     *
     * @package orderTotal
     * @copyright Copyright 2003-2007 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: ot_paymentmodulefee.php 2 2010-09-17 03:38:17Z numinix $
     */
      
    class ot_paymentmodulefee {
        var 
    $title$output;

        function 
    ot_paymentmodulefee() {
          
    $this->code 'ot_paymentmodulefee';
          
    $this->title MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_TITLE;
          
    $this->description MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_DESCRIPTION;
          
    $this->sort_order MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_SORT_ORDER;
          
    $this->payment_modules explode(','MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_PAYMENT_MODULES); 
          
    $this->output = array();
        }

        function 
    process() {
          global 
    $order$currencies;

          if (
    MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_FEE_ALLOW == 'true') {
            switch (
    MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_DESTINATION) {
              case 
    'national':
                if (
    $order->delivery['country_id'] == STORE_COUNTRY$pass true; break;
              case 
    'international':
                if (
    $order->delivery['country_id'] != STORE_COUNTRY$pass true; break;
              case 
    'both':
                
    $pass true; break;
              default:
                
    $pass false; break;
            }

            if ((
    $pass == true) && in_array($_SESSION['payment'], $this->payment_modules)) {
              
    $charge_it 'true';
              if (
    $charge_it == 'true') {
                
    $tax_address zen_get_tax_locations();
                
    $tax zen_get_tax_rate(MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_TAX_CLASS$tax_address['country_id'], $tax_address['zone_id']);
                
    $tax_description zen_get_tax_description(MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_TAX_CLASS$tax_address['country_id'], $tax_address['zone_id']);
                
    $key array_search($_SESSION['payment'], $this->payment_modules);
                
    $this->payment_fees explode(','MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_FEE);
                
    $this->payment_fee $this->payment_fees[$key]; 
    // calculate from flat fee or percentage
                
    if (substr($this->payment_fee, -1) == '%') {
                  
    $payment_module_fee = ($order->info['subtotal'] * ($this->payment_fee/100));
                } else {
                  
    $payment_module_fee $this->payment_fee;
                }


                
    $order->info['tax'] += zen_calculate_tax($payment_module_fee$tax);
                
    $order->info['tax_groups']["$tax_description"] += zen_calculate_tax($payment_module_fee$tax);
                
    $order->info['total'] += $payment_module_fee zen_calculate_tax($payment_module_fee$tax);
                if (
    DISPLAY_PRICE_WITH_TAX == 'true') {
                  
    $payment_module_fee += zen_calculate_tax($payment_module_fee$tax);
                }

                
    $this->output[] = array('title' => $this->title ':',
                                        
    'text' => $currencies->format($payment_module_feetrue$order->info['currency'], $order->info['currency_value']),
                                        
    'value' => $payment_module_fee);
              }
            }
          }
        }

        function 
    check() {
          global 
    $db;
          if (!isset(
    $this->_check)) {
            
    $check_query "select configuration_value
                            from " 
    TABLE_CONFIGURATION "
                            where configuration_key = 'MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_STATUS'"
    ;

            
    $check_query $db->Execute($check_query);
            
    $this->_check $check_query->RecordCount();
          }

          return 
    $this->_check;
        }

        function 
    keys() {
          return array(
    'MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_STATUS''MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_SORT_ORDER''MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_FEE''MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_FEE_ALLOW''MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_PAYMENT_MODULES''MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_DESTINATION''MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_TAX_CLASS');
        }

        function 
    install() {
          global 
    $db;
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('This module is installed', 'MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_STATUS', 'true', '', '6', '1','zen_cfg_select_option(array(\'true\'), ', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_SORT_ORDER', '500', 'Sort order of display.', '6', '2', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Allow Payment Module Fee', 'MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_FEE_ALLOW', 'false', 'Do you want to allow payment module fees?', '6', '3', 'zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('Payment Modules', 'MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_PAYMENT_MODULES', 'paypalwpp,paypal', 'Enter the payment module codes separate by commas (no spaces)', '6', '4', '', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('Fee', 'MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_FEE', '2%,5', 'For Percentage Calculation - include a % Example: 10%<br />For a flat amount just enter the amount - Example: 5 for $5.00', '6', '5', '', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Attach Payment Module Fee On Orders Made', 'MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_DESTINATION', 'both', 'Attach payment module fee for orders sent to the set destination.', '6', '6', 'zen_cfg_select_option(array(\'national\', \'international\', \'both\'), ', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_ORDER_TOTAL_PAYMENTMODULEFEE_TAX_CLASS', '0', 'Use the following tax class on the payment module fee.', '6', '7', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
        }

        function 
    remove() {
          global 
    $db;
          
    $db->Execute("delete from " TABLE_CONFIGURATION " where configuration_key in ('" implode("', '"$this->keys()) . "')");
        }
      }
    ?>
    Here's how they both function.
    PRICE SENSITIVE DISOUNT: offers a discount based on subtotal. This discount is automatically calculated and does not have any restrictions or any other trigger factors.

    PAYMENT MODULE FEE/DISCOUNT: offers a discount based on a specified payment method.

    What I am trying to acheive:
    I want to use the payment module discount. This mod only offers two types of discounts to be set. Either a set percentage discount (i.e. 10%) or a tiered discount($10 off $100, $20 off $200, etc). I want to offer a tiered percentage discount (i.e. 10% off $100, 20% off $200, etc.) this is where the "PRICE SENSITIVE DISCOUNT MOD" comes in. That mod DOES have the tiered percentage discount option. I am trying to use THAT function on the "PAYMENT MODULE FEE MOD" but I don't know how to do this...

    I'm trying to be as clear as possible. Can anyone help? Please?

  3. #13
    Join Date
    Sep 2010
    Posts
    612
    Plugin Contributions
    0

    Default Re: Percentage discount based on order total?

    No one?

  4. #14
    Join Date
    Sep 2010
    Posts
    612
    Plugin Contributions
    0

    Default Re: Percentage discount based on order total?

    Can anyone help? If any moderator reads this can I put this post in the other add ons category? It would also be relevant there...but I don't want to get in trouble for reposting.

  5. #15
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    10,511
    Plugin Contributions
    126

    Default Re: Percentage discount based on order total?

    You're going to have to hire someone to do this work for you.
    That Software Guy. My Store: Zen Cart Support
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  6. #16
    Join Date
    Sep 2010
    Posts
    612
    Plugin Contributions
    0

    Default Re: Percentage discount based on order total?

    Bummer! It seems like something that would be easy...hmmm..

    You up for it? PM me?

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Discount percentage dependant on order total
    By mithaimate in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 2
    Last Post: 2 Aug 2010, 04:37 AM
  2. Discount based on total weight of order
    By stehodges in forum Setting Up Specials and SaleMaker
    Replies: 4
    Last Post: 3 May 2007, 03:43 AM

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