Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2012
    Posts
    9
    Plugin Contributions
    0

    red flag Help with db query and custom field in ot tax module

    Hi, I have altered the ot_tax.php page and carried out an db query to check whether the vat exempt box was checked or not. If it was then the price should show without the vat, if it wasnt then the prices show with the vat.

    Although I havent done the coding for the prices to show without vat. I just put an echo "you are vat exempt" just to see whether it worked or not. But all i get now is a blank page, no matter whether the checkbox is checked or not.

    To be honest, I dont even know if I am editing the correct file or not.

    But here is the code

    Code:
    <?php
    /**
     * ot_tax order-total module
     *
     * @package orderTotal
     * @copyright Copyright 2003-2010 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_tax.php 17018 2010-07-27 07:25:41Z drbyte $
     */
     
     $dbhost = 'localhost';
    $dbuser = 'myusername';
    $dbpass = 'mypassword';
    
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql');
    
    $dbname = 'amobilit_zen';
    mysql_select_db($dbname);
    
    $query = mysql_query('SELECT customers_vatexemptconfirm FROM customers WHERE customers_vatexemptconfirm = "1"');
    
    if ($query)
    {
    
    echo "You are VAT exempt";
    
    } else {
    
      class ot_tax {
        var $title, $output;
    
        function ot_tax() {
          $this->code = 'ot_tax';
          $this->title = MODULE_ORDER_TOTAL_TAX_TITLE;
          $this->description = MODULE_ORDER_TOTAL_TAX_DESCRIPTION;
          $this->sort_order = MODULE_ORDER_TOTAL_TAX_SORT_ORDER;
    
          $this->output = array();
        }
    
        function process() {
          global $order, $currencies;
    
          reset($order->info['tax_groups']);
          $taxDescription = '';
          $taxValue = 0;
          if (STORE_TAX_DISPLAY_STATUS == 1)
          {
            $taxAddress = zen_get_tax_locations();
            $result = zen_get_all_tax_descriptions($taxAddress['country_id'], $taxAddress['zone_id']);
            if (count($result) > 0)
            {
              foreach ($result as $description)
              {
                if (!isset($order->info['tax_groups'][$description]))
                {
                  $order->info['tax_groups'][$description] = 0;
                }
              }
            }
          }
          if (count($order->info['tax_groups']) > 1 && isset($order->info['tax_groups'][0])) unset($order->info['tax_groups'][0]);
          while (list($key, $value) = each($order->info['tax_groups'])) {
            if (SHOW_SPLIT_TAX_CHECKOUT == 'true')
            {
              if ($value > 0 or ($value == 0 && STORE_TAX_DISPLAY_STATUS == 1 )) {
                $this->output[] = array('title' => ((is_numeric($key) && $key == 0) ? TEXT_UNKNOWN_TAX_RATE :  $key) . ':',
                                        'text' => $currencies->format($value, true, $order->info['currency'], $order->info['currency_value']),
                                        'value' => $value);
              }
            } else
            {
              if ($value > 0 || ($value == 0 && STORE_TAX_DISPLAY_STATUS == 1))
              {
                $taxDescription .= ((is_numeric($key) && $key == 0) ? TEXT_UNKNOWN_TAX_RATE :  $key) . ' + ';
                $taxValue += $value;
              }
            }
          }
          if (SHOW_SPLIT_TAX_CHECKOUT != 'true' && ($taxValue > 0 or STORE_TAX_DISPLAY_STATUS == 1))
          {
            $this->output[] = array(
                            'title' => substr($taxDescription, 0 , strlen($taxDescription)-3) . ':' ,
                            'text' => $currencies->format($taxValue, true, $order->info['currency'], $order->info['currency_value']) ,
                            'value' => $taxValue);
          }
        }
    
        function check() {
    	  global $db;
          if (!isset($this->_check)) {
            $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_TAX_STATUS'");
            $this->_check = $check_query->RecordCount();
          }
    
          return $this->_check;
        }
    
        function keys() {
          return array('MODULE_ORDER_TOTAL_TAX_STATUS', 'MODULE_ORDER_TOTAL_TAX_SORT_ORDER');
        }
    
        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_TAX_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_TAX_SORT_ORDER', '300', 'Sort order of display.', '6', '2', now())");
        }
    
        function remove() {
    	  global $db;
          $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
        }
      }
      
      
    ?>
    Any help or giudance is much appreciated

  2. #2
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Help with db query and checkout

    No, you can't do that with a class, or well at least, if you do, you'll run into some dependency challenges.

    It would be more in keeping with normal usage if you were to put your logic inside the process() method of the class, instead of your current approach which completely skips even the declaration of the class at all if your db query fails.

    But even moreso, your query has no logic in it to identify which customer you're querying about in the first place.

    I'd suggest it might be a lot more efficient if you used one of the already-built tax-exempt plugins instead.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. Replies: 9
    Last Post: 12 Jul 2023, 12:26 AM
  2. v154 Help with a SQL Query for Query Builder
    By lindasdd in forum Managing Customers and Orders
    Replies: 2
    Last Post: 24 Mar 2016, 01:18 PM
  3. Tax problem with sales tax and trinity payjunction module
    By rdxrdx in forum Addon Payment Modules
    Replies: 0
    Last Post: 1 Jul 2010, 10:25 PM
  4. Help with custom shipping module
    By gofer_p in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 4 Mar 2009, 09:19 PM
  5. Help with custom shipping module
    By FuzzyJared in forum Addon Shipping Modules
    Replies: 0
    Last Post: 7 Dec 2006, 07:33 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