Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

TAX Being Calculated on Price, LOADED 5


magtaf69

Recommended Posts

Hello everyone.

 

I have a problem that the tax is being calculated on the price, but what I want is the tax to be shown next to the price or seperate from the price. I am using Deniza_Dove theme for Loaded 4 or 5.

 

I have a weight on each product set to 1 and taxable goods, the sort order in the admin is set to:

 

Sub-Total: $659.00

Quantity Discount (10%): -$65.90

UPS Ground (Best Way): $7.00

VA TAX 4.5%: $29.65

Total: $626.78

 

I want for tax to be charged on all orders for NY, and its set to 8.25%. It does show the tax at check out but I want the prices shown with the original tax, not with them included.

 

I have modified the catalog/includes/application_top.php to say false for tax, but I get an error.

 

Can anyone help me. i have set a test ID so it can be tested so every can see what mean:

 

The website is www.healthyremedies.biz/catalog/default.php

Here is the login so you can test:

user id: [email protected]

password: test01

Link to comment
Share on other sites

just went to your site to test and found an error in the following page:

 

http://www.healthyremedies.biz/catalog/che...out_payment.php

 

Warning: Cannot modify header information - headers already sent by (output started at /home/healthyr/public_html/catalog/includes/application_top.php:514) in /home/healthyr/public_html/catalog/includes/functions/general.php on line 23

 

 

this usually means there is a blank space preceeding the opening <?php

or after the closing ?>

 

you should open the file and check for blank spaces

Link to comment
Share on other sites

Did not find any spaces, but her are the codes for application_top and general, maybe you can tell me what is causing the error:

 

 

catalog/includes/application_top.php

<?php

/*

 $Id: application_top.php,v 1.5 2002/12/02 20:31:09 wilt Exp $



 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2002 osCommerce



 Released under the GNU General Public License

*/



// Start the clock for the page parse time log

 define('PAGE_PARSE_START_TIME', microtime());



// Set the level of error reporting

 error_reporting(E_ALL & ~E_NOTICE);



// Check if register_globals is enabled.

// Since this is a temporary measure this message is hardcoded. The requirement will be removed before 2.2 is finalized.

 if (function_exists('ini_get')) {

   ini_get('register_globals') or exit('FATAL ERROR: register_globals is disabled in php.ini, please enable it!');

 }



// Disable use_trans_sid as tep_href_link() does this manually

 if (function_exists('ini_set')) {

   ini_set('session.use_trans_sid', 0);

 }



// Set the local configuration parameters - mainly for developers

 if (file_exists('includes/local/configure.php')) include('includes/local/configure.php');



// include server parameters

 require('includes/configure.php');



// Define the project version

 define('PROJECT_VERSION', 'osCommerce 2.2-CVS');



// define the filenames used in the project

 define('FILENAME_ACCOUNT', 'account.php');

 define('FILENAME_ACCOUNT_EDIT', 'account_edit.php');

 define('FILENAME_ACCOUNT_EDIT_PROCESS', 'account_edit_process.php');

 define('FILENAME_ACCOUNT_HISTORY', 'account_history.php');

 define('FILENAME_ACCOUNT_HISTORY_INFO', 'account_history_info.php');

 define('FILENAME_ADDRESS_BOOK', 'address_book.php');

 define('FILENAME_ADDRESS_BOOK_PROCESS', 'address_book_process.php');

 define('FILENAME_ADVANCED_SEARCH', 'advanced_search.php');

 define('FILENAME_ADVANCED_SEARCH_RESULT', 'advanced_search_result.php');

 define('FILENAME_ALSO_PURCHASED_PRODUCTS', 'also_purchased_products.php'); // This is the bottom of product_info.php (found in modules)

 define('FILENAME_CCVAL_FUNCTION', 'ccval.php');

 define('FILENAME_CHECKOUT_ADDRESS', 'checkout_address.php');

 define('FILENAME_CHECKOUT_CONFIRMATION', 'checkout_confirmation.php');

 define('FILENAME_CHECKOUT_PAYMENT', 'checkout_payment.php');

 define('FILENAME_CHECKOUT_PAYMENT_ADDRESS', 'checkout_payment_address.php');

 define('FILENAME_CHECKOUT_PROCESS', 'checkout_process.php');

 define('FILENAME_CHECKOUT_SHIPPING', 'checkout_shipping.php');

 define('FILENAME_CHECKOUT_SHIPPING_ADDRESS', 'checkout_shipping_address.php');

 define('FILENAME_CHECKOUT_SUCCESS', 'checkout_success.php');

 define('FILENAME_CONTACT_US', 'contact_us.php');

 define('FILENAME_CONDITIONS', 'conditions.php');

 define('FILENAME_CREATE_ACCOUNT', 'create_account.php');

 define('FILENAME_CREATE_ACCOUNT_PROCESS', 'create_account_process.php');

 define('FILENAME_CREATE_ACCOUNT_SUCCESS', 'create_account_success.php');

 define('FILENAME_DEFAULT', 'default.php');

 define('FILENAME_DOWNLOAD', 'download.php');

 define('FILENAME_INFO_SHOPPING_CART', 'info_shopping_cart.php');

 define('FILENAME_LATEST_NEWS', 'latest_news.php');

 define('FILENAME_LOGIN', 'login.php');

 define('FILENAME_LOGOFF', 'logoff.php');

 define('FILENAME_NEW_PRODUCTS', 'new_products.php'); // This is the middle of default.php (found in modules)

 define('FILENAME_PASSWORD_CRYPT', 'password_funcs.php');

 define('FILENAME_PASSWORD_FORGOTTEN', 'password_forgotten.php');

 define('FILENAME_POPUP_IMAGE', 'popup_image.php');

 define('FILENAME_POPUP_SEARCH_HELP', 'popup_search_help.php');

 define('FILENAME_PRIVACY', 'privacy.php');

 define('FILENAME_POLLCOLLECT', 'pollcollect.php');

 define('FILENAME_PRODUCT_INFO', 'product_info.php');

 define('FILENAME_PRODUCT_LISTING', 'product_listing_col.php');

 define('FILENAME_PRODUCT_NOTIFICATIONS', 'product_notifications.php');

 define('FILENAME_PRODUCT_REVIEWS', 'product_reviews.php');

 define('FILENAME_PRODUCT_REVIEWS_INFO', 'product_reviews_info.php');

 define('FILENAME_PRODUCT_REVIEWS_WRITE', 'product_reviews_write.php');

 define('FILENAME_PRODUCTS_NEW', 'products_new.php');

 define('FILENAME_REDIRECT', 'redirect.php');

 define('FILENAME_REVIEWS', 'reviews.php');

 define('FILENAME_SHIPPING', 'shipping.php');

 define('FILENAME_SHOPPING_CART', 'shopping_cart.php');

 define('FILENAME_SPECIALS', 'specials.php');

define('FILENAME_DEFAULT_SPECIALS', 'default_specials.php');

 define('FILENAME_TELL_A_FRIEND', 'tell_a_friend.php');

 define('FILENAME_UPCOMING_PRODUCTS', 'upcoming_products.php'); // This is the bottom of default.php (found in modules)

 define('FILENAME_MEMBERS', 'members.php');

 

// define the database table names used in the project

 define('TABLE_ADDRESS_BOOK', 'address_book');

 define('TABLE_ADDRESS_FORMAT', 'address_format');

 define('TABLE_BANNERS', 'banners');

 define('TABLE_BANNERS_HISTORY', 'banners_history');

 define('TABLE_CATEGORIES', 'categories');

 define('TABLE_CATEGORIES_DESCRIPTION', 'categories_description');

 define('TABLE_CONFIGURATION', 'configuration');

 define('TABLE_CONFIGURATION_GROUP', 'configuration_group');

 define('TABLE_COUNTER', 'counter');

 define('TABLE_COUNTER_HISTORY', 'counter_history');

 define('TABLE_COUNTRIES', 'countries');

 define('TABLE_CURRENCIES', 'currencies');

 define('TABLE_CUSTOMERS', 'customers');

 define('TABLE_CUSTOMERS_BASKET', 'customers_basket');

 define('TABLE_CUSTOMERS_BASKET_ATTRIBUTES', 'customers_basket_attributes');

 define('TABLE_CUSTOMERS_INFO', 'customers_info');

 define('TABLE_LANGUAGES', 'languages');

 define('TABLE_LATEST_NEWS', 'latest_news');

 define('TABLE_MANUFACTURERS', 'manufacturers');

 define('TABLE_MANUFACTURERS_INFO', 'manufacturers_info');

 define('TABLE_ORDERS', 'orders');

 define('TABLE_ORDERS_PRODUCTS', 'orders_products');

 define('TABLE_ORDERS_PRODUCTS_ATTRIBUTES', 'orders_products_attributes');

 define('TABLE_ORDERS_PRODUCTS_DOWNLOAD', 'orders_products_download');

 define('TABLE_ORDERS_STATUS', 'orders_status');

 define('TABLE_ORDERS_STATUS_HISTORY', 'orders_status_history');

 define('TABLE_ORDERS_TOTAL', 'orders_total');

 define('TABLE_PRODUCTS', 'products');

 define('TABLE_PRODUCTS_ATTRIBUTES', 'products_attributes');

 define('TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD', 'products_attributes_download');

 define('TABLE_PRODUCTS_DESCRIPTION', 'products_description');

 define('TABLE_PRODUCTS_NOTIFICATIONS', 'products_notifications');

 define('TABLE_PRODUCTS_OPTIONS', 'products_options');

 define('TABLE_PRODUCTS_OPTIONS_VALUES', 'products_options_values');

 define('TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS', 'products_options_values_to_products_options');

 define('TABLE_PRODUCTS_TO_CATEGORIES', 'products_to_categories');

 define('TABLE_REVIEWS', 'reviews');

 define('TABLE_REVIEWS_DESCRIPTION', 'reviews_description');

 define('TABLE_SESSIONS', 'sessions');

 define('TABLE_SPECIALS', 'specials');

 define('TABLE_TAX_CLASS', 'tax_class');

 define('TABLE_TAX_RATES', 'tax_rates');

 define('TABLE_GEO_ZONES', 'geo_zones');

 define('TABLE_ZONES_TO_GEO_ZONES', 'zones_to_geo_zones');

 define('TABLE_WHOS_ONLINE', 'whos_online');

 define('TABLE_ZONES', 'zones');

// featured products mod

define('FILENAME_FEATURED', 'featured.php');

define('FILENAME_FEATURED_PRODUCTS', 'featured_products.php'); // This is the featured products page

define('TABLE_FEATURED', 'featured');

// customization for the design layout

 define('TAX_DECIMAL_PLACES', 2); // Pad the tax value this amount of decimal places

 define('DISPLAY_PRICE_WITH_TAX', true); // Display prices with tax (true) or without tax (false)

 //define('BOX_WIDTH', 155); // how wide the boxes should be in pixels (default: 125)



// Control what fields of the customer table are used

 define('ACCOUNT_GENDER', 'false');

 define('ACCOUNT_DOB', 'false');

 define('ACCOUNT_COMPANY', 'false');

 define('ACCOUNT_SUBURB', 'false');

 define('ACCOUNT_STATE', 'true');



// Categories Box: recursive products count

 define('SHOW_COUNTS', 'true'); // show category count: true=Yes False=No

 define('USE_RECURSIVE_COUNT', 'true'); // recursive count: true=Yes False=No



// check to see if php implemented session management functions - if not, include php3/php4 compatible session class

 if (!function_exists('session_start')) {

   define('PHP_SESSION_NAME', 'sID');

   define('PHP_SESSION_SAVE_PATH', '/tmp');



   include(DIR_WS_CLASSES . 'sessions.php');

 }



// define how the session functions will be used

 require(DIR_WS_FUNCTIONS . 'sessions.php');

 tep_session_name('osCsid');



// include the database functions

 require(DIR_WS_FUNCTIONS . 'database.php');



// make a connection to the database... now

 tep_db_connect() or die('Unable to connect to database server!');



// set the application parameters (can be modified through the administration tool)

 $configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION . '');

 while ($configuration = tep_db_fetch_array($configuration_query)) {

   define($configuration['cfgKey'], $configuration['cfgValue']);

 }

// set the pollbooth parameters (can be modified through the administration tool)

 $configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from phesis_poll_config');

 while ($configuration = tep_db_fetch_array($configuration_query)) {

   define($configuration['cfgKey'], $configuration['cfgValue']);

 }

// Get variables from $PATH_INFO

 if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') {

   if (strlen($PATH_INFO) > 1) {

     $PHP_SELF = str_replace($PATH_INFO,'',$PHP_SELF);

     $vars = explode('/', substr($PATH_INFO, 1));

     while (list(, $var) = each($vars)) { 

       list(, $val) = each($vars); 

       $HTTP_GET_VARS[$var] = $val; 

       $GLOBALS[$var] = $val; 

     }

   }

 }



// include cache functions if enabled

 if (USE_CACHE == 'true') include(DIR_WS_FUNCTIONS . 'cache.php');



// include shopping cart class

 require(DIR_WS_CLASSES . 'shopping_cart.php');



// include navigation history class

 require(DIR_WS_CLASSES . 'navigation_history.php');



// some code to solve compatibility issues

 require(DIR_WS_FUNCTIONS . 'compatibility.php');



// lets start our session

  if ($HTTP_POST_VARS[tep_session_name()]) {   

    tep_session_id($HTTP_POST_VARS[tep_session_name()]);   

  }   

  if ( (getenv('HTTPS') == 'on') && ($HTTP_GET_VARS[tep_session_name()]) ) {   

    tep_session_id($HTTP_GET_VARS[tep_session_name()]);   

  } 

  if (function_exists('session_set_cookie_params')) {

   session_set_cookie_params(0, substr(DIR_WS_CATALOG, 0, -1));

 }



 tep_session_start();



// Create the cart & Fix the cart if necesary

 if (is_object($cart)) {

   if (PHP_VERSION < 4) {

     $broken_cart = $cart;

     $cart = new shoppingCart;

     $cart->unserialize($broken_cart);

   }

 } else {

   tep_session_register('cart');

   $cart = new shoppingCart;

 }



// include currencies class and create an instance

 require(DIR_WS_CLASSES . 'currencies.php');

 $currencies = new currencies();



// include the mail classes

 require(DIR_WS_CLASSES . 'mime.php');

 require(DIR_WS_CLASSES . 'email.php');



// language

 if ( (!$language) || ($HTTP_GET_VARS['language']) ) {

   if (!$language) {

     tep_session_register('language');

     tep_session_register('languages_id');

   }



   include(DIR_WS_CLASSES . 'language.php');

   $lng = new language($HTTP_GET_VARS['language']);



   if (!$HTTP_GET_VARS['language']) $lng->get_browser_language();



   $language = $lng->language['directory'];

   $languages_id = $lng->language['id'];

 }



// include the language translations

 require(DIR_WS_LANGUAGES . $language . '.php');



// define our general functions used application-wide

 require(DIR_WS_FUNCTIONS . 'general.php');

 require(DIR_WS_FUNCTIONS . 'html_output.php');



// currency

 if ( (!$currency) || ($HTTP_GET_VARS['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $currency) ) ) {

   if (!$currency) tep_session_register('currency');



   if ($HTTP_GET_VARS['currency']) {

     $currency = tep_currency_exists($HTTP_GET_VARS['currency']);

     if (!$currency) $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;

   } else {

     $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;

   }

 }



// navigation history

 if (tep_session_is_registered('navigation')) {

   if (PHP_VERSION < 4) {

     $broken_navigation = $navigation;

     $navigation = new navigationHistory;

     $navigation->unserialize($broken_navigation);

   }

 } else {

   tep_session_register('navigation');

   $navigation = new navigationHistory;

 }

 $navigation->add_current_page();

// BOF: WebMakers.com Added: Functions Library

   include(DIR_WS_FUNCTIONS . 'webmakers_added_functions.php');

// EOF: WebMakers.com Added: Functions Library

// Shopping cart actions

 if ($HTTP_GET_VARS['action']) {

   if (DISPLAY_CART == 'true') {

     $goto =  FILENAME_SHOPPING_CART;

     $parameters = array('action', 'cPath', 'products_id', 'pid');

   } else {

     $goto = basename($PHP_SELF);

     if ($HTTP_GET_VARS['action'] == 'buy_now') {

       $parameters = array('action', 'pid', 'products_id');

     } else {

       $parameters = array('action', 'pid');

     }

   }

   switch ($HTTP_GET_VARS['action']) {

     // customer wants to update the product quantity in their shopping cart

     case 'update_product' : for ($i=0; $i<sizeof($HTTP_POST_VARS['products_id']);$i++) {

                               if (in_array($HTTP_POST_VARS['products_id'][$i], (is_array($HTTP_POST_VARS['cart_delete']) ? $HTTP_POST_VARS['cart_delete'] : array()))) {

                                 $cart->remove($HTTP_POST_VARS['products_id'][$i]);

                               } else {

                                 if (PHP_VERSION < 4) {

                                   // if PHP3, make correction for lack of multidimensional array.

                                   reset($HTTP_POST_VARS);

                                   while (list($key, $value) = each($HTTP_POST_VARS)) {

                                     if (is_array($value)) {

                                       while (list($key2, $value2) = each($value)) {

                                         if (ereg ("(.*)][(.*)", $key2, $var)) {

                                           $id2[$var[1]][$var[2]] = $value2;

                                         }

                                       }

                                     }

                                   }

                                   $attributes = ($id2[$HTTP_POST_VARS['products_id'][$i]]) ? $id2[$HTTP_POST_VARS['products_id'][$i]] : '';

                                 } else {

                                   $attributes = ($HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]]) ? $HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]] : '';

                                 }

                                 $cart->add_cart($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['cart_quantity'][$i], $attributes, false);

                               }

                             }

                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters), 'NONSSL'));

                             break;

     // customer adds a product from the products page

     case 'add_product' :    if (ereg('^[0-9]+$', $HTTP_POST_VARS['products_id'])) {

                               $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);

                             }

                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters), 'NONSSL'));

                             break;

     // performed by the 'buy now' button in product listings and review page

     case 'buy_now' :        if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {

                               tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id'], 'NONSSL'));

                             } else {

                               $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);

                               tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters), 'NONSSL'));

                             }

                             break;

     case 'notify' :         if (tep_session_is_registered('customer_id')) {

                               if ($HTTP_GET_VARS['products_id']) {

                                 $notify = array($HTTP_GET_VARS['products_id']);

                               } elseif ($HTTP_POST_VARS['notify']) {

                                 $notify = $HTTP_POST_VARS['notify'];

                               } else {

                                 tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')), 'NONSSL'));

                               }

                               for ($i=0; $i<sizeof($notify); $i++) {

                                 $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $notify[$i] . "' and customers_id = '" . $customer_id . "'");

                                 $check = tep_db_fetch_array($check_query);

                                 if ($check['count'] < 1) {

                                   tep_db_query("insert into " . TABLE_PRODUCTS_NOTIFICATIONS . " (products_id, customers_id, date_added) values ('" . $notify[$i] . "', '" . $customer_id . "', now())");

                                 }

                               }

                               tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')), 'NONSSL'));

                             } else {

                               $navigation->set_snapshot();

                               tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

                             }

                             break;

     case 'notify_remove' :  if (tep_session_is_registered('customer_id')) {

                               $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");

                               $check = tep_db_fetch_array($check_query);

                               if ($check['count'] > 0) {

                                 tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");

                               }

                               tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')), 'NONSSL'));

                             } else {

                               $navigation->set_snapshot();

                               tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

                             }

                             break;

     case 'cust_order' :     if (tep_session_is_registered('customer_id')) {

                               if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) {

                                 tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid'], 'NONSSL'));

                               } else {

                                 $cart->add_cart($HTTP_GET_VARS['pid'], 1);

                               }

                             }

                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters), 'NONSSL'));

                             break;

   }

 }



// include the who's online functions

 require(DIR_WS_FUNCTIONS . 'whos_online.php');

 tep_update_whos_online();



// Include the password crypto functions

 require(DIR_WS_FUNCTIONS . FILENAME_PASSWORD_CRYPT);



// Include validation functions (right now only email address)

 require(DIR_WS_FUNCTIONS . 'validations.php');



// split-page-results

 require(DIR_WS_CLASSES . 'split_page_results.php');



// infobox

//  require(DIR_WS_CLASSES . 'boxes.php');

//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

//Site thema configuration

 $configuration_query = tep_db_query("select  configuration_key as themaKey, configuration_value as themaValue from " . TABLE_CONFIGURATION . " where configuration_key = 'SITE_THEMA'");

 $configuration = tep_db_fetch_array($configuration_query);

 define($configuration['themaKey'], $configuration['themaValue']);

 if($configuration['themaKey']==""){

 define(THEMA_STYLE, "stylesheet.css");

 // infobox

 require(DIR_WS_CLASSES . 'boxes.php'); }

 else{

 // Thema_infobox

 require(DIR_WS_CLASSES . 'thema/' . SITE_THEMA . '/thema_boxes.php');

 define(THEMA_STYLE, DIR_WS_CLASSES . "thema/" . SITE_THEMA . "/stylesheet.css");

 }

//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



// auto activate and expire banners

 require(DIR_WS_FUNCTIONS . 'banner.php');

 tep_activate_banners();

 tep_expire_banners();



// auto expire special products

 require(DIR_WS_FUNCTIONS . 'specials.php');

 tep_expire_specials();

// auto expire featured products

 require(DIR_WS_FUNCTIONS . 'featured.php');

 tep_expire_featured();

// calculate category path

 if ($HTTP_GET_VARS['cPath']) {

   $cPath = $HTTP_GET_VARS['cPath'];

 } elseif ($HTTP_GET_VARS['products_id'] && !$HTTP_GET_VARS['manufacturers_id']) {

   $cPath = tep_get_product_path($HTTP_GET_VARS['products_id']);

 } else {

   $cPath = '';

 }

 if (strlen($cPath) > 0) {

   $cPath_array = tep_parse_category_path($cPath);

   $cPath = implode('_', $cPath_array);

   $current_category_id = $cPath_array[(sizeof($cPath_array)-1)];

 } else {

   $current_category_id = 0;

 }



 require(DIR_WS_CLASSES . 'breadcrumb.php');

 $breadcrumb = new breadcrumb;



 $breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);

 $breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));



 if (isset($cPath_array)) {

   for ($i = 0, $n = sizeof($cPath_array); $i < $n; $i++) {

     $categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $cPath_array[$i] . "' and language_id='" . $languages_id . "'");

if (tep_db_num_rows($categories_query) > 0) {

     $categories = tep_db_fetch_array($categories_query);

     $breadcrumb->add($categories['categories_name'], tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));

} else {

  break;

 }

   }

 } elseif ($HTTP_GET_VARS['manufacturers_id']) {

   $manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . $HTTP_GET_VARS['manufacturers_id'] . "'");

   $manufacturers = tep_db_fetch_array($manufacturers_query);

   $breadcrumb->add($manufacturers['manufacturers_name'], tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id']));

 }



 if ($HTTP_GET_VARS['products_id']) {

   $model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "'");

   $model = tep_db_fetch_array($model_query);

   $breadcrumb->add($model['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));

 }



// set which precautions should be checked

 define('WARN_INSTALL_EXISTENCE', 'true');

 define('WARN_CONFIG_WRITEABLE', 'true');

 define('WARN_SESSION_DIRECTORY_NOT_WRITEABLE', 'true');

 define('WARN_SESSION_AUTO_START', 'true');

 define('WARN_DOWNLOAD_DIRECTORY_NOT_READABLE', 'true');

 require(DIR_WS_INCLUDES . 'add_application_top.php');

// BOF: WebMakers.com Added: Header Tags Controller v1.0

 require(DIR_WS_FUNCTIONS . 'header_tags.php');

// Clean out HTML comments from ALT tags etc.

 require(DIR_WS_FUNCTIONS . 'clean_html_comments.php');

// Also used by: WebMakers.com Added: FREE-CALL FOR PRICE

// EOF: WebMakers.com Added: Header Tags Controller v1.0

//================================================================

if ( ($HTTP_GET_VARS['currency']) ) {

  tep_session_register('kill_sid');

  $kill_sid=false;

 }

if ( ($HTTP_GET_VARS['language']) ) {

 tep_session_register('kill_sid');

 $kill_sid = false;

 }

if (basename($_SERVER['HTTP_REFERER']) == 'allprods.php' ) $kill_sid = true;

if ( ( !tep_session_is_registered('customer_id') ) && ( $cart->count_contents()==0 ) && (!tep_session_is_registered('kill_sid') ) ) $kill_sid = true;

if (basename($PHP_SELF) == FILENAME_LOGIN ) $kill_sid = false;

//================================================================





// include local zz_application_top.php

 require('includes/local/zz_application_top.php');

?>

 

catalog/includes/functions/general.php

<?php

/*

$Id: general.php,v 1.4 2002/11/29 21:27:07 wilt Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright (c) 2002 osCommerce

 

Released under the GNU General Public License

*/

 

////

// Stop from parsing any further PHP code

function tep_exit() {

tep_session_close();

exit();

}

 

////

// Redirect to another page or site

function tep_redirect($url) {

header('Location: ' . $url);

tep_exit();

}

 

////

// Error message wrapper

// When optional parameters are provided, it closes the application

// (ie, halts the current application execution task)

function tep_error_message($error_message, $close_application = false, $close_application_error = '') {

echo $error_message;

 

if ($close_application) {

die($close_application_error);

}

}

 

////

// Return a random row from a database query

function tep_random_select($query) {

 

$random_product = '';

$random_query = tep_db_query($query);

$num_rows = tep_db_num_rows($random_query);

if ($num_rows > 0) {

$random_row = tep_rand(0, ($num_rows - 1));

tep_db_data_seek($random_query, $random_row);

$random_product = tep_db_fetch_array($random_query);

}

return $random_product;

}

 

////

// Return a product's name

// TABLES: products

function tep_get_products_name($product_id) {

global $languages_id;

 

$product_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $product_id . "' and language_id = '" . $languages_id . "'");

$product = tep_db_fetch_array($product_query);

 

return $product['products_name'];

}

 

////

// Return a product's description

// TABLES: products description

function tep_get_products_description($product_id) {

global $languages_id;

 

$product_query = tep_db_query("select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $product_id . "' and language_id = '" . $languages_id . "'");

$product_description = tep_db_fetch_array($product_query);

 

return $product_description['products_description'];

}

 

////

// Return a product's special price (returns nothing if there is no offer)

// TABLES: products

function tep_get_products_special_price($product_id) {

$product_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $product_id . "' and status");

$product = tep_db_fetch_array($product_query);

 

return $product['specials_new_products_price'];

}

 

////

// Return a product's stock

// TABLES: products

function tep_get_products_stock($products_id) {

$products_id = tep_get_prid($products_id);

$stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'");

$stock_values = tep_db_fetch_array($stock_query);

return $stock_values['products_quantity'];

}

 

////

// Check if the required stock is available

// If insufficent stock is available return an out of stock message

function tep_check_stock($products_id, $products_quantity) {

$stock_left = tep_get_products_stock($products_id) - $products_quantity;

$out_of_stock = '';

if ($stock_left < 0) {

$out_of_stock = '<span class="markProductOutOfStock">' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '</span>';

}

return $out_of_stock;

}

 

////

// Break a word in a string if it is longer than a specified length ($len)

function tep_break_string($string, $len, $break_char = '-') {

$l = 0;

$output = '';

for ($i=0; $i<strlen($string); $i++) {

$char = substr($string, $i, 1);

if ($char != ' ') {

$l++;

} else {

$l = 0;

}

if ($l > $len) {

$l = 1;

$output .= $break_char;

}

$output .= $char;

}

 

return $output;

}

 

////

// Return all HTTP GET variables, except those passed as a parameter

function tep_get_all_get_params($exclude_array = '') {

global $HTTP_GET_VARS;

 

if ($exclude_array == '') $exclude_array = array();

 

$get_url = '';

if (is_array($HTTP_GET_VARS)) {

reset($HTTP_GET_VARS);

while (list($key, $value) = each($HTTP_GET_VARS)) {

if ((strlen($value) > 0) && ($key != session_name()) && ($key != 'error') && (!in_array($key, $exclude_array))) {

$get_url .= $key . '=' . rawurlencode(stripslashes($value)) . '&';

}

}

}

return $get_url;

}

 

////

// Returns an array with countries

// TABLES: countries

function tep_get_countries($countries_id = '', $with_iso_codes = false) {

$countries_array = array();

if ($countries_id) {

if ($with_iso_codes) {

$countries = tep_db_query("select countries_name, countries_iso_code_2, countries_iso_code_3 from " . TABLE_COUNTRIES . " where countries_id = '" . $countries_id . "' order by countries_name");

$countries_values = tep_db_fetch_array($countries);

$countries_array = array('countries_name' => $countries_values['countries_name'],

'countries_iso_code_2' => $countries_values['countries_iso_code_2'],

'countries_iso_code_3' => $countries_values['countries_iso_code_3']);

} else {

$countries = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . $countries_id . "'");

$countries_values = tep_db_fetch_array($countries);

$countries_array = array('countries_name' => $countries_values['countries_name']);

}

} else {

$countries = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " order by countries_name");

while ($countries_values = tep_db_fetch_array($countries)) {

$countries_array[] = array('countries_id' => $countries_values['countries_id'],

'countries_name' => $countries_values['countries_name']);

}

}

 

return $countries_array;

}

 

////

// Alias function to tep_get_countries, which also returns the countries iso codes

function tep_get_countries_with_iso_codes($countries_id) {

return tep_get_countries($countries_id, true);

}

 

////

// Generate a path to categories

function tep_get_path($current_category_id = '') {

global $cPath_array;

 

if ($current_category_id) {

if (sizeof($cPath_array) == 0) {

$cPath_new = $current_category_id;

} else {

$cPath_new = '';

$last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . $cPath_array[(sizeof($cPath_array)-1)] . "'");

$last_category = tep_db_fetch_array($last_category_query);

$current_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . $current_category_id . "'");

$current_category = tep_db_fetch_array($current_category_query);

if ($last_category['parent_id'] == $current_category['parent_id']) {

for ($i=0; $i<(sizeof($cPath_array)-1); $i++) {

$cPath_new .= '_' . $cPath_array[$i];

}

} else {

for ($i=0; $i<sizeof($cPath_array); $i++) {

$cPath_new .= '_' . $cPath_array[$i];

}

}

$cPath_new .= '_' . $current_category_id;

if (substr($cPath_new, 0, 1) == '_') {

$cPath_new = substr($cPath_new, 1);

}

}

} else {

$cPath_new = implode('_', $cPath_array);

}

 

return 'cPath=' . $cPath_new;

}

 

////

// Returns the clients browser

function tep_browser_detect($component) {

global $HTTP_USER_AGENT;

 

$result = stristr($HTTP_USER_AGENT, $component);

 

return $result;

}

 

////

// Alias function to tep_get_countries()

function tep_get_country_name($country_id) {

$country_array = tep_get_countries($country_id);

 

return $country_array['countries_name'];

}

 

////

// Returns the zone (State/Province) name

// TABLES: zones

function tep_get_zone_name($country_id, $zone_id, $default_zone) {

$zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . $country_id . "' and zone_id = '" . $zone_id . "'");

if (tep_db_num_rows($zone_query)) {

$zone = tep_db_fetch_array($zone_query);

return $zone['zone_name'];

} else {

return $default_zone;

}

}

 

////

// Returns the zone (State/Province) code

// TABLES: zones

function tep_get_zone_code($country_id, $zone_id, $default_zone) {

$zone_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . $country_id . "' and zone_id = '" . $zone_id . "'");

if (tep_db_num_rows($zone_query)) {

$zone = tep_db_fetch_array($zone_query);

return $zone['zone_code'];

} else {

return $default_zone;

}

}

 

////

// Wrapper function for round() for php3 compatibility

function tep_round($value, $precision) {

if (PHP_VERSION < 4) {

$exp = pow(10, $precision);

return round($value * $exp) / $exp;

} else {

return round($value, $precision);

}

}

 

////

// Returns the tax rate for a zone / class

// TABLES: tax_rates, zones_to_geo_zones

function tep_get_tax_rate($class_id, $country_id = -1, $zone_id = -1) {

global $customer_zone_id, $customer_country_id;

 

if ( ($country_id == -1) && ($zone_id == -1) ) {

if (!tep_session_is_registered('customer_id')) {

$country_id = STORE_COUNTRY;

$zone_id = STORE_ZONE;

} else {

$country_id = $customer_country_id;

$zone_id = $customer_zone_id;

}

}

 

$tax_query = tep_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za ON tr.tax_zone_id = za.geo_zone_id left join " . TABLE_GEO_ZONES . " tz ON tz.geo_zone_id = tr.tax_zone_id WHERE (za.zone_country_id IS NULL OR za.zone_country_id = '0' OR za.zone_country_id = '" . $country_id . "') AND (za.zone_id IS NULL OR za.zone_id = '0' OR za.zone_id = '" . $zone_id . "') AND tr.tax_class_id = '" . $class_id . "' GROUP BY tr.tax_priority");

if (tep_db_num_rows($tax_query)) {

$tax_multiplier = 0;

while ($tax = tep_db_fetch_array($tax_query)) {

$tax_multiplier += $tax['tax_rate'];

}

return $tax_multiplier;

} else {

return 0;

}

}

 

////

// Return the tax description for a zone / class

// TABLES: tax_rates;

function tep_get_tax_description($zone_id, $class_id) {

$tax_query = tep_db_query("select tax_description from " . TABLE_TAX_RATES . " where tax_zone_id = '" . $zone_id . "' and tax_class_id = '" . $class_id . "'");

if (tep_db_num_rows($tax_query)) {

$tax = tep_db_fetch_array($tax_query);

return $tax['tax_description'];

} else {

return TEXT_UNKNOWN_TAX_RATE;

}

}

 

////

// Add tax to a products price

function tep_add_tax($price, $tax) {

global $currencies;

 

if (DISPLAY_PRICE_WITH_TAX == true) {

return tep_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + tep_calculate_tax($price, $tax);

} else {

return tep_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);

}

}

 

// Calculates Tax rounding the result

function tep_calculate_tax($price, $tax) {

global $currencies;

 

return tep_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);

}

 

////

// Return the number of products in a category

// TABLES: products, products_to_categories, categories

function tep_count_products_in_category($category_id, $include_inactive = false) {

$products_count = 0;

if ($include_inactive) {

$products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . $category_id . "'");

} else {

$products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = 1 and p2c.categories_id = '" . $category_id . "'");

}

$products = tep_db_fetch_array($products_query);

$products_count += $products['total'];

 

if (USE_RECURSIVE_COUNT == 'true') {

$child_categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . $category_id . "'");

if (tep_db_num_rows($child_categories_query)) {

while ($child_categories = tep_db_fetch_array($child_categories_query)) {

$products_count += tep_count_products_in_category($child_categories['categories_id'], $include_inactive);

}

}

}

 

return $products_count;

}

 

////

// Return true if the category has subcategories

// TABLES: categories

function tep_has_category_subcategories($category_id) {

$child_category_query = tep_db_query("select count(*) as count from " . TABLE_CATEGORIES . " where parent_id = '" . $category_id . "'");

$child_category = tep_db_fetch_array($child_category_query);

 

if ($child_category['count'] > 0) {

return true;

} else {

return false;

}

}

 

////

// Returns the address_format_id for the given country

// TABLES: countries;

function tep_get_address_format_id($country_id) {

$address_format_query = tep_db_query("select address_format_id as format_id from " . TABLE_COUNTRIES . " where countries_id = '" . $country_id . "'");

if (tep_db_num_rows($address_format_query)) {

$address_format = tep_db_fetch_array($address_format_query);

return $address_format['format_id'];

} else {

return '1';

}

}

 

////

// Return a formatted address

// TABLES: address_format

function tep_address_format($address_format_id, $address, $html, $boln, $eoln) {

$address_format_query = tep_db_query("select address_format as format from " . TABLE_ADDRESS_FORMAT . " where address_format_id = '" . $address_format_id . "'");

$address_format = tep_db_fetch_array($address_format_query);

 

$company = addslashes($address['company']);

$firstname = addslashes($address['firstname']);

$lastname = addslashes($address['lastname']);

$street = addslashes($address['street_address']);

$suburb = addslashes($address['suburb']);

$city = addslashes($address['city']);

$state = addslashes($address['state']);

$country_id = $address['country_id'];

$zone_id = $address['zone_id'];

$postcode = addslashes($address['postcode']);

$zip = $postcode;

$country = tep_get_country_name($country_id);

$state = tep_get_zone_code($country_id, $zone_id, $state);

 

if ($html) {

// HTML Mode

$HR = '<hr>';

$hr = '<hr>';

if ( ($boln == '') && ($eoln == "n") ) { // Values not specified, use rational defaults

$CR = '<br>';

$cr = '<br>';

$eoln = $cr;

} else { // Use values supplied

$CR = $eoln . $boln;

$cr = $CR;

}

} else {

// Text Mode

$CR = $eoln;

$cr = $CR;

$HR = '----------------------------------------';

$hr = '----------------------------------------';

}

 

$statecomma = '';

$streets = $street;

if ($suburb != '') $streets = $street . $cr . $suburb;

if ($firstname == '') $firstname = addslashes($address['name']);

if ($country == '') $country = addslashes($address['country']);

if ($state != '') $statecomma = $state . ', ';

 

$fmt = $address_format['format'];

eval("$address = "$fmt";");

$address = stripslashes($address);

 

if ( (ACCOUNT_COMPANY == 'true') && (tep_not_null($company)) ) {

$address = $company . $cr . $address;

}

 

return $boln . $address . $eoln;

}

 

////

// Return a formatted address

// TABLES: customers, address_book

function tep_address_label($customers_id, $address_id = 1, $html = false, $boln = '', $eoln = "n") {

$address_query = tep_db_query("select entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_suburb as su

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...