Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2007
    Posts
    64
    Plugin Contributions
    0

    Default Help understanding ot_taxexempt module

    Hi all,

    I am just about done with cloning the TaxExempt module to work for me as a Surcharge module. My problem is that I do not know what I can take out of the Tax_Exempt Module.

    I have replaced the following
    PHP Code:
        function process() {
          global 
    $db$order$currencies;
          
    $tax_exempt_query $db->Execute("select customers_tax_exempt from " TABLE_CUSTOMERS " where customers_id = '" $_SESSION['customer_id'] . "'");
          if (
    $tax_exempt_query->fields['customers_tax_exempt'] != '0') {
            
    $tax_exempt_discount $db->Execute("select tax_exempt_name, tax_exempt_percentage from " TABLE_TAX_EXEMPT " where
                                            tax_exempt_id = '" 
    $tax_exempt_query->fields['customers_tax_exempt'] . "'");
            
    $order_total $this->get_order_total();
            
    $gift_vouchers $_SESSION['cart']->gv_only();
            
    $discount = ($order_total $gift_vouchers) * $tax_exempt_discount->fields['tax_exempt_percentage'] / 100;

            
    //Absolute Solutions Edit
            
    $tod_amount 0;
            
    $product_count sizeof($order->products);
            
    $products $order->products;
            
    $taxable_order 0.00;
            
    $customer_exempt_taxation floatval($tax_exempt_discount->fields['tax_exempt_percentage']);
            for (
    $p 0$p $product_count$p++) {
              if (
    round($products[$p]['tax'] - $customer_exempt_taxation4) == 0) {
                
    $taxable_order += ($products[$p]['qty'] * $products[$p]['final_price']);
              }
            }


    //        echo 'Taxable Order = ' . $taxable_order;
            
            
    $discount = ($taxable_order $gift_vouchers) * $customer_exempt_taxation 100;
            
            
    $od_amount zen_round($discount2);
            if (
    $this->calculate_tax != "none") {
              
    $tod_amount $this->calculate_tax_deduction($order_total$od_amount$this->calculate_taxtrue);
    //          $od_amount = $this->calculate_credit($order_total);
            
    }
            
    $this->deduction $od_amount;
            if (
    $discount ) {
              
    $order->info['total'] -= $this->deduction;
              
    $this->output[] = array('title' => $this->title ':',
                                      
    'text' => '-' $currencies->format($this->deductiontrue$order->info['currency'], $order->info['currency_value']),
                                      
    'value' => $this->deduction);
            }
          }
        } 
    with this, as I did not need any of that other code.

    PHP Code:
        function process() {
          global 
    $db$order;
          
    $hazmat_query $db->Execute("select count (*) from " PRODUCTS " where products_model = '" .'22-0060-01' "' OR '".'PART # 22-0080-01'."' OR '".'PART # 22-0090-00'."' OR '".'PART # 22-0910-00'."' ");
          if (
    $hazmat_query->fields['products_model'] != '0') {
            
    $order_total $this->get_order_total();
            
    $hazmatCharge = ($order_total 20*$hazmat_query);

              }
            } 
    This is the entire ot_hazmat file I have created.

    PHP Code:
    <?php
    //
    // +----------------------------------------------------------------------+
    // |zen-cart Open Source E-commerce                                       |
    // +----------------------------------------------------------------------+
    // | Copyright (c) 2004 The zen-cart developers                           |
    // |                                                                      |
    // | http://www.zen-cart.com/index.php                                    |
    // |                                                                      |
    // | Portions Copyright (c) 2003 osCommerce                               |
    // +----------------------------------------------------------------------+
    // | This source file is subject to version 2.0 of the GPL license,       |
    // | that is bundled with this package in the file LICENSE, and is        |
    // | available through the world-wide-web at the following url:           |
    // | http://www.zen-cart.com/license/2_0.txt.                             |
    // | If you did not receive a copy of the zen-cart license and are unable |
    // | to obtain it through the world-wide-web, please send a note to       |
    // | [email protected] so we can mail you a copy immediately.          |
    // +----------------------------------------------------------------------+
    // $Id: ot_hazmat.php 827 2004-12-16 18:17:08Z wilt $
    //

      
    class ot_hazmat {
        var 
    $title$output;

        function 
    ot_hazmat() {
          
    $this->code 'ot_hazmat';
          
    $this->title MODULE_ORDER_TOTAL_HAZMAT_TITLE;
          
    $this->description MODULE_ORDER_TOTAL_HAZMAT_DESCRIPTION;
          
    $this->sort_order MODULE_ORDER_TOTAL_HAZMAT_SORT_ORDER;
          
    $this->include_shipping MODULE_ORDER_TOTAL_HAZMAT_INC_SHIPPING;
          
    $this->include_tax MODULE_ORDER_TOTAL_HAZMAT_INC_TAX;
          
    $this->calculate_tax MODULE_ORDER_TOTAL_HAZMAT_CALC_TAX;
          
    $this->credit_tax MODULE_ORDER_TOTAL_HAZMAT_CREDIT_TAX;
          
    $this->credit_class true;

          
    $this->output = array();
        }

        function 
    process() {
          global 
    $db$order$currencies;
          
    $hazmat_query $db->Execute("select count (*) from " PRODUCTS " where products_model = '" .'22-0060-01' "' OR '".'PART # 22-0080-01'."' OR '".'PART # 22-0090-00'."' OR '".'PART # 22-0910-00'."' ");
          if (
    $hazmat_query->fields['products_model'] != '0') {
            
    $order_total $this->get_order_total();
            
    $hazmatCharge = ($order_total 20*$hazmat_query);

              }
            }



        function 
    get_order_total() {
          global 
    $order;
          
    $order_total $order->info['total'];
          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 
    pre_confirmation_check($order_total) {
          global 
    $order$db;
          if (
    $this->include_shipping == 'false'$order_total -= $order->info['shipping_cost'];
          if (
    $this->include_tax == 'false'$order_total -= $order->info['tax'];
               
    $hazmat_query $db->Execute("select count (*) from " PRODUCTS " where products_model = '" .'22-0060-01' "' OR '".'PART # 22-0080-01'."' OR '".'PART # 22-0090-00'."' OR '".'PART # 22-0910-00'."' ");
          if (
    $hazmat_query->fields['products_model'] != '0') {
            
    $order_total $this->get_order_total();
            
    $hazmatCharge = ($order_total 20*$hazmat_query);

              }
            }
         

        function 
    credit_selection() {
          return 
    $selection;
        }

        function 
    collect_posts() {
        }

        function 
    update_credit_account($i) {
        }

        function 
    apply_credit() {
        }

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

          return 
    $this->_check;
        }

        function 
    keys() {
          return array(
    'MODULE_ORDER_TOTAL_HAZMAT_STATUS''MODULE_ORDER_TOTAL_HAZMAT_SORT_ORDER''MODULE_ORDER_TOTAL_HAZMAT_INC_SHIPPING''MODULE_ORDER_TOTAL_HAZMAT_INC_TAX''MODULE_ORDER_TOTAL_HAZMAT_CALC_TAX''MODULE_ORDER_TOTAL_HAZMAT_TAX_CLASS');
        }

        function 
    install() {
          global 
    $db;
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, sort_order, set_function, date_added) values ('This module is installed', 'MODULE_ORDER_TOTAL_HAZMAT_STATUS', 'true', '', '1','zen_cfg_select_option(array(\'true\'), ', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_HAZMAT_SORT_ORDER', '290', 'Sort order of display.', '2', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, sort_order, set_function ,date_added) values ('Include Shipping', 'MODULE_ORDER_TOTAL_HAZMAT_INC_SHIPPING', 'false', 'Include Shipping in calculation', '5', 'zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, sort_order, set_function ,date_added) values ('Include Tax', 'MODULE_ORDER_TOTAL_HAZMAT_INC_TAX', 'true', 'Include Tax in calculation.','6','zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, sort_order, set_function ,date_added) values ('Re-calculate Tax', 'MODULE_ORDER_TOTAL_HAZMAT_CALC_TAX', 'Standard', 'Re-Calculate Tax', '7','zen_cfg_select_option(array(\'None\', \'Standard\', \'Credit Note\'), ', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_ORDER_TOTAL_HAZMAT_TAX_CLASS', '0', 'Use the following tax class when treating Tax Exemption as Credit Note.', '0', '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()) . "')");
        }
      }
    ?>
    Am I missing any necessary pieces or do I have any thing in there that will keep this from working?

    Thank you,

    TheMusician

  2. #2
    Join Date
    Jun 2007
    Posts
    64
    Plugin Contributions
    0

    Default Re: Help understanding ot_taxexempt module

    I have the module loading and allowing me to get to the checkout phase. It is not calculating the correct order total though. It does not add the $20 per model.

    This is the working code,

    PHP Code:
    <?php
    //
    // +----------------------------------------------------------------------+
    // |zen-cart Open Source E-commerce                                       |
    // +----------------------------------------------------------------------+
    // | Copyright (c) 2004 The zen-cart developers                           |
    // |                                                                      |
    // | http://www.zen-cart.com/index.php                                    |
    // |                                                                      |
    // | Portions Copyright (c) 2003 osCommerce                               |
    // +----------------------------------------------------------------------+
    // | This source file is subject to version 2.0 of the GPL license,       |
    // | that is bundled with this package in the file LICENSE, and is        |
    // | available through the world-wide-web at the following url:           |
    // | http://www.zen-cart.com/license/2_0.txt.                             |
    // | If you did not receive a copy of the zen-cart license and are unable |
    // | to obtain it through the world-wide-web, please send a note to       |
    // | [email protected] so we can mail you a copy immediately.          |
    // +----------------------------------------------------------------------+
    // $Id: ot_hazmat.php 827 2004-12-16 18:17:08Z wilt $
    //

      
    class ot_hazmat {
        var 
    $title$output;

        function 
    ot_hazmat() {
          
    $this->code 'ot_hazmat';
          
    $this->title MODULE_ORDER_TOTAL_HAZMAT_TITLE;
          
    $this->description MODULE_ORDER_TOTAL_HAZMAT_DESCRIPTION;
          
    $this->sort_order MODULE_ORDER_TOTAL_HAZMAT_SORT_ORDER;
          
    $this->include_shipping MODULE_ORDER_TOTAL_HAZMAT_INC_SHIPPING;
          
    $this->include_tax MODULE_ORDER_TOTAL_HAZMAT_INC_TAX;
          
    $this->calculate_tax MODULE_ORDER_TOTAL_HAZMAT_CALC_TAX;
          
    $this->credit_tax MODULE_ORDER_TOTAL_HAZMAT_CREDIT_TAX;
          
    $this->credit_class true;

          
    $this->output = array();
        }

        function 
    process() {
          global 
    $db$order$currencies;
          
    $hazmat_query $db->Execute("select count(*) from " bos_products " where 

    products_model = '" 
    .'22-0060-01' "'");
          if (
    $hazmat_query->fields['products_model'] != '0') {
            
    $order_total $this->get_order_total();
            
    $hazmatCharge = ($order_total 20*$hazmat_query);

              }
            }



        function 
    get_order_total() {
          global 
    $order;
          
    $order_total $order->info['total'];
          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 
    pre_confirmation_check($order_total) {
          global 
    $order$db;
          if (
    $this->include_shipping == 'false'$order_total -= $order->info['shipping_cost'];
          if (
    $this->include_tax == 'false'$order_total -= $order->info['tax'];
               
    $hazmat_query $db->Execute("select count(*) from " bos_products " where 

    products_model = '" 
    .'22-0060-01' "'");
          if (
    $hazmat_query->fields['products_model'] != '0') {
            
    $order_total $this->get_order_total();
            
    $hazmatCharge = ($order_total 20*$hazmat_query);

              }
            }
         

        function 
    credit_selection() {
          return 
    $selection;
        }

        function 
    collect_posts() {
        }

        function 
    update_credit_account($i) {
        }

        function 
    apply_credit() {
        }

        function 
    check() {
          global 
    $db;
          if (!isset(
    $this->_check)) {
            
    $check_query $db->Execute("select configuration_value from " TABLE_CONFIGURATION 

    " where configuration_key = 'MODULE_ORDER_TOTAL_HAZMAT_STATUS'");
            
    $this->_check $check_query->RecordCount();
          }

          return 
    $this->_check;
        }

        function 
    keys() {
          return array(
    'MODULE_ORDER_TOTAL_HAZMAT_STATUS'

    'MODULE_ORDER_TOTAL_HAZMAT_SORT_ORDER''MODULE_ORDER_TOTAL_HAZMAT_INC_SHIPPING'

    'MODULE_ORDER_TOTAL_HAZMAT_INC_TAX''MODULE_ORDER_TOTAL_HAZMAT_CALC_TAX'

    'MODULE_ORDER_TOTAL_HAZMAT_TAX_CLASS');
        }

        function 
    install() {
          global 
    $db;
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, 

    configuration_key, configuration_value, configuration_description, sort_order, set_function, 

    date_added) values ('This module is installed', 'MODULE_ORDER_TOTAL_HAZMAT_STATUS', 'true', 

    '', '1','zen_cfg_select_option(array(\'true\'), ', now())"
    );
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, 

    configuration_key, configuration_value, configuration_description, sort_order, date_added) 

    values ('Sort Order', 'MODULE_ORDER_TOTAL_HAZMAT_SORT_ORDER', '290', 'Sort order of 

    display.', '2', now())"
    );
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, 

    configuration_key, configuration_value, configuration_description, sort_order, set_function 

    ,date_added) values ('Include Shipping', 'MODULE_ORDER_TOTAL_HAZMAT_INC_SHIPPING', 'false', 

    'Include Shipping in calculation', '5', 'zen_cfg_select_option(array(\'true\', \'false\'), 

    ', now())"
    );
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, 

    configuration_key, configuration_value, configuration_description, sort_order, set_function 

    ,date_added) values ('Include Tax', 'MODULE_ORDER_TOTAL_HAZMAT_INC_TAX', 'true', 'Include 

    Tax in calculation.','6','zen_cfg_select_option(array(\'true\', \'false\'), ', now())"
    );
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, 

    configuration_key, configuration_value, configuration_description, sort_order, set_function 

    ,date_added) values ('Re-calculate Tax', 'MODULE_ORDER_TOTAL_HAZMAT_CALC_TAX', 'Standard', 

    'Re-Calculate Tax', '7','zen_cfg_select_option(array(\'None\', \'Standard\', \'Credit 

    Note\'), ', now())"
    );
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, 

    configuration_key, configuration_value, configuration_description, sort_order, use_function, 

    set_function, date_added) values ('Tax Class', 'MODULE_ORDER_TOTAL_HAZMAT_TAX_CLASS', '0', 

    'Use the following tax class when treating Tax Exemption as Credit Note.', '0', 

    '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()) . "')");
        }
      }
    ?>
    Any help would be appreciated

    TheMusician

  3. #3
    Join Date
    Jun 2007
    Posts
    64
    Plugin Contributions
    0

    Default Re: Help understanding ot_taxexempt module

    I echoed out the result of $hazmatCharge and it calculates correctly. I just need it to show up in the actual order total. Any hints as to what part of the code that is?

    Thank you

 

 

Similar Threads

  1. help understanding use of $messagestack in php files
    By wonged in forum General Questions
    Replies: 0
    Last Post: 26 Apr 2011, 06:37 AM
  2. Help in understanding 'Layout Boxes Controller'
    By kirkzeus in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 23 Jun 2008, 10:25 PM
  3. Need Help Understanding javascript_validation
    By webomat in forum Addon Payment Modules
    Replies: 2
    Last Post: 2 Jan 2007, 07:21 AM
  4. Help! need help understanding override system
    By JenBaby in forum Templates, Stylesheets, Page Layout
    Replies: 17
    Last Post: 12 Dec 2006, 04:06 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR