Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Multi_Vendor_Shipping new thread


blucollarguy

Recommended Posts

The code in the MVS version of Zones needs to be different so that it can pull the handling charges from the Vendors database table instead of the default store configuration. That code should be correct. The code that calculates the tax from the tax class also seems to be correct. I don't see any problems here. Which doesn't necessarily mean that there aren't any bugs, just that I dont see any.

 

Regards

Jim

 

Hi Jim,

 

In zones.php, is the variable $shipping_weight the weight of items being shipped with that vendor, or the total shipping weight of the whole order?

 

Also, with regards to my shipping tax issue, could a piece of code be inserted to calculate the shipping tax amount in zones.php before this line:

$shipping_cost = ($shipping * $shipping_num_boxes) + $handling;

 

so we have something like this:

// Calculate shipping amount with tax if applicable
	 if (constant('MODULE_SHIPPING_ZONES_TAX_CLASS_' . $vendors_id) > 0 ) { 
	 $shp_tax_rate = tep_get_tax_rate(constant('MODULE_SHIPPING_ZONES_TAX_CLASS_' . $vendors_id), $order->delivery['country']['id'], $order->delivery['zone_id']);
	 $shp_tax_amount = $shipping_cost * ($shp_tax_rate / 100);
	 $shipping_cost_without_tax = $shipping_cost;
	 $shipping_cost = $shipping_cost_without_tax + $shp_tax_amount;

	 }

 

Let me know what you think.

 

Cheers,

 

Paul.

Link to comment
Share on other sites

I am not familiar with either one. But, I have run into some as of yet unknow problems with the PayPal IPN 2.8 and 3.0. I haven't figured out yet if it involves the "fasteasycheckout" contrib that I added as well, but there is an issue there.

 

Good luck, Craig :)

 

 

Does anyone have some experience with using MVS 1.1 together with the "fasteasycheckout" contrib (http://www.oscommerce.com/community/contributions,3469)

 

Both contributions are too complex for my php knowledge to overwiev, if they bother each other....

 

Thanks in advance

greetings from Germany

 

Philipp

Link to comment
Share on other sites

The original issue with the shipping tax was the fact that the "module" couldn't register properly because of the "array" of vendor modules. The ot_shipping wants one number to use as a tax and one number to use as shipping price, we can't give that with MVS because each Vendor may or may not be taxing the shipping cost.

 

Not sure where to go with this at this point.

 

Craig :)

 

Just looking back at my last suggestion, I've just realised I'd be charging tax on the handling fee as well. So what I suggest is in zones.php after the line:

 

$shipping_cost = ($shipping * $shipping_num_boxes) + $handling;

 

Have something like this:

 

// Calculate shipping amount with tax if applicable
	 if (constant('MODULE_SHIPPING_ZONES_TAX_CLASS_' . $vendors_id) > 0 ) { 
	 $shp_tax_rate = tep_get_tax_rate(constant('MODULE_SHIPPING_ZONES_TAX_CLASS_' . $vendors_id), $order->delivery['country']['id'], $order->delivery['zone_id']);
	 $shipping_cost_without_tax = $shipping_cost - $handling;
	 $shp_tax_amount = $shipping_cost_without_tax * ($shp_tax_rate / 100);		 
	 $shipping_cost = $shipping_cost_without_tax + $shp_tax_amount + $handling;
	 }

 

I'm trying to work out if the variable $shipping_weight used in MVS version of zones.php is the weight of items shipped with the vendor or the total weight of the order...

 

All the best,

 

Paul.

Link to comment
Share on other sites

I think I am invisisble I have posted a question and I haven't got an answer

Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Link to comment
Share on other sites

I think I am invisisble I have posted a question and I haven't got an answer

I think most may have missed what the question is. :-"

I'm assuming you want to know if MVS 1.1 will handle your needs and for the most part yes, and I'm sure that you cna either set the pricing structure for the discount over amount or add in another contribution.

Link to comment
Share on other sites

So are you saying that it can be possible?

 

like this:

 

Any Motherboards-----> 20% of Total order

 

Any Monitor-------> 20% of Total order

 

etc.

 

and my Gift Items are up to $100.00 is $10.00 anything over $100.00 is 10% of the total order

Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Link to comment
Share on other sites

Hi,

 

I tried posting two questions and haven't gotten a response from anyone...I need help with getting MVS1.1 to work with WPP. I've attempted merging the checkout_shipping.php file with WINmerge 4 times and still get errors. Would anyone be willing to install it successfully for me for a price. Thanks.

Link to comment
Share on other sites

Hi,

 

I tried posting two questions and haven't gotten a response from anyone...I need help with getting MVS1.1 to work with WPP. I've attempted merging the checkout_shipping.php file with WINmerge 4 times and still get errors. Would anyone be willing to install it successfully for me for a price. Thanks.

It is against forum policy to post paid work or to post anything related to paid services.

Link to comment
Share on other sites

Hi Jim,

 

In zones.php, is the variable $shipping_weight the weight of items being shipped with that vendor, or the total shipping weight of the whole order?

 

Also, with regards to my shipping tax issue, could a piece of code be inserted to calculate the shipping tax amount in zones.php <snip>

 

Let me know what you think.

 

Cheers,

 

Paul.

The $shipping_weight should be the weight of the shipment from the current vendor. This depends on the preceding code to set up the global variable correctly. Another reason to avoid globals.

 

Your tax calculation looks correct to me. If you want the tax invisibly added to shipping costs, that should do the job. For the general case, we probably need to be able to display tax separately, so it makes sense to leave the tax rate here:

	  if ($this->tax_class($vendors_id) > 0) {
	   $this->quotes['tax'] = tep_get_tax_rate($this->tax_class($vendors_id), $order->delivery['country']['id'], $order->delivery['zone_id']);
  }

and do the calculation outside the module.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

so this contribution is what I really need?

MVS will allow you to set separate rates for your computer items and your gift items. It's a good solution for that part.

 

There are no standard modules that calculate shipping as a percentage of cost. You could approximate this with the Table module, but it won't be exact. I believe that there is a contribution for a percentage module. You could use that if you modify it to work with MVS. There are instructions in the file modules.txt in the MVS distribution that tell you how to do this.

 

So yes, MVS plus another contribution will do what you want, but you'll need to do some work to get there.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

MVS will allow you to set separate rates for your computer items and your gift items. It's a good solution for that part.

 

There are no standard modules that calculate shipping as a percentage of cost. You could approximate this with the Table module, but it won't be exact. I believe that there is a contribution for a percentage module. You could use that if you modify it to work with MVS. There are instructions in the file modules.txt in the MVS distribution that tell you how to do this.

 

So yes, MVS plus another contribution will do what you want, but you'll need to do some work to get there.

 

Regards

Jim

 

Jim well part of is what I want but most part is by percentages of total order. so there is no way of doing percentage of total cost on this?

Edited by mtechama

Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Link to comment
Share on other sites

Jim well part of is what I want but most part is by percentages of total order. so there is no way of doing percentage of total cost on this?

There are at least two ways:

1. Approximate it using the Table module.

2. Modify the table module using this contribution and do percentages directly.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

so the table will let me do this

 

gifts 1=$10 for up to $100.00 after that is 10% for over $100 so the table will be like this: 100:10, 1000:10%

 

computers 20% same way like this first table

 

will it work for 1 store tho?

Edited by mtechama

Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Link to comment
Share on other sites

It is against forum policy to post paid work or to post anything related to paid services.

 

I apologize. I was unaware of the forum policy on this. I guess I'll have to deal without having the module installed.

Link to comment
Share on other sites

The $shipping_weight should be the weight of the shipment from the current vendor. This depends on the preceding code to set up the global variable correctly. Another reason to avoid globals.

 

Your tax calculation looks correct to me. If you want the tax invisibly added to shipping costs, that should do the job. For the general case, we probably need to be able to display tax separately, so it makes sense to leave the tax rate here:

	  if ($this->tax_class($vendors_id) > 0) {
	   $this->quotes['tax'] = tep_get_tax_rate($this->tax_class($vendors_id), $order->delivery['country']['id'], $order->delivery['zone_id']);
  }

and do the calculation outside the module.

 

Regards

Jim

 

Hi Jim,

 

I'm happy with the shipping tax now, and very impressed with the MVS module as a whole.

 

I'd like to include the customers telephone number in the e-mail sent to the vendor. Could you suggest a modification to checkout_process.php to achieve this? Also, as a possible improvement, what do you think of the idea of being able to set some options for what details are included in the e-mail to the vendor in Vendor Manager?

 

Many thanks,

 

Paul.

Link to comment
Share on other sites

so the table will let me do this

 

gifts 1=$10 for up to $100.00 after that is 10% for over $100 so the table will be like this: 100:10, 1000:10%

 

computers 20% same way like this first table

 

will it work for 1 store tho?

 

 

Jim is this way it should work for 1 store?

Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Link to comment
Share on other sites

Would this module allow you to set multiple free freight amount for specific items?

 

For instance, we have some items the we can offer free shipping on any order over $50 and other items we'd want to have free shipping set at $500.

 

thanks,

 

nate

Link to comment
Share on other sites

Hi Jim,

 

I'm happy with the shipping tax now, and very impressed with the MVS module as a whole.

 

I'd like to include the customers telephone number in the e-mail sent to the vendor. Could you suggest a modification to checkout_process.php to achieve this? Also, as a possible improvement, what do you think of the idea of being able to set some options for what details are included in the e-mail to the vendor in Vendor Manager?

 

Many thanks,

 

Paul.

The telephone number should be easy to do. Add

customers_telephone,

to the $delivery_address_query string in line 331. Anywhere in the list is fine. Then add

 . $vendor_delivery_address_list['customers_telephone'] . '<br><br>'

to the end of Line 355 (just before the semicolon. The last bit could be placed wherever you want it in the email string (Lines 346 to 356 in my copy.)

 

Having options like this that can be turned off or on in the Admin sounds like a good idea. If you can think of other things (besides telephone number) that should be added, post them here. They can be added to a later edition of MVS. If Craig agrees that this is a good idea, of course.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Does anyone have some experience with using MVS 1.1 together with the "fasteasycheckout" contrib (http://www.oscommerce.com/community/contributions,3469)

 

Both contributions are too complex for my php knowledge to overwiev, if they bother each other....

 

Thanks in advance

Yes, can be done. FEC has a few bugs with the paymeny modules that require yet more work.

 

But they do play nice.

 

Craig :)

Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: [email protected]

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Link to comment
Share on other sites

The telephone number should be easy to do. Add
customers_telephone,

to the $delivery_address_query string in line 331. Anywhere in the list is fine. Then add

 . $vendor_delivery_address_list['customers_telephone'] . '<br><br>'

to the end of Line 355 (just before the semicolon. The last bit could be placed wherever you want it in the email string (Lines 346 to 356 in my copy.)

 

Having options like this that can be turned off or on in the Admin sounds like a good idea. If you can think of other things (besides telephone number) that should be added, post them here. They can be added to a later edition of MVS. If Craig agrees that this is a good idea, of course.

 

Regards

Jim

I agree, such options would be very good for MVS.

 

All suggestions concerning MVS(added functionality, optional components, whatever) please don't hesitate to post them, the worst we can do is not add them.

 

This forum has helped us proceed with MVS very nicely, I don't plan to go backwards in that regard.

 

Craig :)

Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: [email protected]

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Link to comment
Share on other sites

I need help I installed the MVS to my Test Site and I got errors:

 

Main Index: Fatal error: Call to undefined function: tep_not_null() in /home/content/m/t/e/mtechamatest/html/catalog/includes/classes/language.php on line 74

 

 

Admin Area:

 

Catalog: Fatal error: Call to undefined function: tep_array_merge() in /home/content/m/t/e/mtechamatest/html/catalog/admin/categories.php on line 686

 

Shipping Modules: Warning: main(/home/content/m/t/e/mtechamatest/html/catalog/includes/languages/english/modules/shipping/old check out code mltship.php): failed to open stream: No such file or directory in /home/content/m/t/e/mtechamatest/html/catalog/admin/modules.php on line 128

 

Warning: main(/home/content/m/t/e/mtechamatest/html/catalog/includes/languages/english/modules/shipping/old check out code mltship.php): failed to open stream: No such file or directory in /home/content/m/t/e/mtechamatest/html/catalog/admin/modules.php on line 128

 

Warning: main(): Failed opening '/home/content/m/t/e/mtechamatest/html/catalog/includes/languages/english/modules/shipping/old check out code mltship.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/content/m/t/e/mtechamatest/html/catalog/admin/modules.php on line 128

 

Fatal error: Cannot redeclare class mltship in /home/content/m/t/e/mtechamatest/html/catalog/includes/modules/shipping/old check out code mltship.php on line 12

Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Link to comment
Share on other sites

I need help I installed the MVS to my Test Site and I got errors:

 

Main Index: Fatal error: Call to undefined function: tep_not_null() in /home/content/m/t/e/mtechamatest/html/catalog/includes/classes/language.php on line 74

Admin Area:

 

Catalog: Fatal error: Call to undefined function: tep_array_merge() in /home/content/m/t/e/mtechamatest/html/catalog/admin/categories.php on line 686

 

Shipping Modules: Warning: main(/home/content/m/t/e/mtechamatest/html/catalog/includes/languages/english/modules/shipping/old check out code mltship.php): failed to open stream: No such file or directory in /home/content/m/t/e/mtechamatest/html/catalog/admin/modules.php on line 128

 

Warning: main(/home/content/m/t/e/mtechamatest/html/catalog/includes/languages/english/modules/shipping/old check out code mltship.php): failed to open stream: No such file or directory in /home/content/m/t/e/mtechamatest/html/catalog/admin/modules.php on line 128

 

Warning: main(): Failed opening '/home/content/m/t/e/mtechamatest/html/catalog/includes/languages/english/modules/shipping/old check out code mltship.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/content/m/t/e/mtechamatest/html/catalog/admin/modules.php on line 128

 

Fatal error: Cannot redeclare class mltship in /home/content/m/t/e/mtechamatest/html/catalog/includes/modules/shipping/old check out code mltship.php on line 12

You have files missing or several blocks of code missing. Double check: admin/includes/functions/general.php and admin/includes/application_top.php

 

You also have a file you apparently renamed "old check out code mltship.php" this file cannot be in this directory with the ".php" extension. If you need to rename a file to keep as a backup, rename it like this: "mltship.php.old_check_out_code" , also, one should never use spaces in file names that you use on the web. Windows is fine with spaces(usually), but Linux(the OS that runs about 90% of the internet, does not like spaces in names.

 

Craig :)

Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: [email protected]

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Link to comment
Share on other sites

here is my admin/includes/application_top.php coding:

 

<?php
/*
 $Id: application_top.php,v 1.1.4.2 2002/06/19 14:14:02 mdima Exp $

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

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/
//changes mltship
define('TABLE_SHIPPING_METHODS', 'shipping_methods');//mltship


//changes featured items
define('FILENAME_FEATURED', 'featured.php'); //featured items
define('TABLE_FEATURED', 'featured');//featured items


//changes paypalipn
define('FILENAME_PAYPALIPN_TRANSACTIONS', 'paypalipn_txn.php'); // PAYPALIPN

// 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);

// 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 application configuration parameters
 require('includes/configure.php');

// Define the project version
 define('PROJECT_VERSION', 'Preview Release 2.2-CVS');

// Used in the "Backup Manager" to compress backups
 define('LOCAL_EXE_GZIP', '/usr/bin/gzip');
 define('LOCAL_EXE_GUNZIP', '/usr/bin/gunzip');
 define('LOCAL_EXE_ZIP', '/usr/local/bin/zip');
 define('LOCAL_EXE_UNZIP', '/usr/local/bin/unzip');

// define the filenames used in the project
 define('FILENAME_BACKUP', 'backup.php');
 define('FILENAME_BANNER_MANAGER', 'banner_manager.php');
 define('FILENAME_BANNER_STATISTICS', 'banner_statistics.php');
 define('FILENAME_CACHE', 'cache.php');
 define('FILENAME_CATALOG_ACCOUNT_HISTORY_INFO', 'account_history_info.php');
 define('FILENAME_CATEGORIES', 'categories.php');
 define('FILENAME_CONFIGURATION', 'configuration.php');
 define('FILENAME_COUNTRIES', 'countries.php');
 define('FILENAME_CURRENCIES', 'currencies.php');
 define('FILENAME_CUSTOMERS', 'customers.php');
 define('FILENAME_DEFAULT', 'index.php');
 define('FILENAME_DEFINE_LANGUAGE', 'define_language.php');
 define('FILENAME_FILE_MANAGER', 'file_manager.php');
 define('FILENAME_GEO_ZONES', 'geo_zones.php');
 define('FILENAME_LANGUAGES', 'languages.php');
 define('FILENAME_MAIL', 'mail.php');
 define('FILENAME_MANUFACTURERS', 'manufacturers.php');
 define('FILENAME_MODULES', 'modules.php');
 define('FILENAME_NEWSLETTERS', 'newsletters.php');
 define('FILENAME_ORDERS', 'orders.php');
 define('FILENAME_ORDERS_INVOICE', 'invoice.php');
 define('FILENAME_ORDERS_PACKINGSLIP', 'packingslip.php');
 define('FILENAME_ORDERS_STATUS', 'orders_status.php');
 define('FILENAME_POPUP_IMAGE', 'popup_image.php');
 define('FILENAME_PRODUCTS_ATTRIBUTES', 'products_attributes.php');
 define('FILENAME_PRODUCTS_EXPECTED', 'products_expected.php');
 define('FILENAME_REVIEWS', 'reviews.php');
 define('FILENAME_SERVER_INFO', 'server_info.php');
 define('FILENAME_SHIPPING_MODULES', 'shipping_modules.php');
 define('FILENAME_SPECIALS', 'specials.php');
 define('FILENAME_STATS_CUSTOMERS', 'stats_customers.php');
 define('FILENAME_STATS_PRODUCTS_PURCHASED', 'stats_products_purchased.php');
 define('FILENAME_STATS_PRODUCTS_VIEWED', 'stats_products_viewed.php');
 define('FILENAME_TAX_CLASSES', 'tax_classes.php');
 define('FILENAME_TAX_RATES', 'tax_rates.php');
 define('FILENAME_WHOS_ONLINE', 'whos_online.php');
 define('FILENAME_ZONES', 'zones.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_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_MANUFACTURERS', 'manufacturers');
 define('TABLE_MANUFACTURERS_INFO', 'manufacturers_info');
 define('TABLE_NEWSLETTERS', 'newsletters');
 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');

// customization for the design layout
 define('TAX_DECIMAL_PLACES', 0); // Pad the tax value this amount of decimal places
 define('BOX_WIDTH', 125); // how wide the boxes should be in pixels (default: 125)

// Control what fields of the customer table are used
 define('ACCOUNT_GENDER', 'true');
 define('ACCOUNT_DOB', 'true');
 define('ACCOUNT_COMPANY', 'false');
 define('ACCOUNT_SUBURB', 'true');
 define('ACCOUNT_STATE', 'true');

// Define how do we update currency exchange rates
// Possible values are 'oanda' 'xe' or ''
 define('CURRENCY_SERVER_PRIMARY', 'oanda');
 define('CURRENCY_SERVER_BACKUP', 'xe');

// 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 application wide parameters
 $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']);
 }

// initialize the logger class
 require(DIR_WS_CLASSES . 'logger.php');

// include shopping cart class
 require(DIR_WS_CLASSES . 'shopping_cart.php');

// some code to solve compatibility issues
 require(DIR_WS_FUNCTIONS . 'compatibility.php');

// 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('osCAdminsID');

// lets start our session
 tep_session_start();
 if (function_exists('session_set_cookie_params')) {
session_set_cookie_params(0, substr(DIR_WS_ADMIN, 0, -1));
 }

// language
 require(DIR_WS_FUNCTIONS . 'languages.php');
 if ( (!$language) || ($HTTP_GET_VARS['language']) ) {
if (!$language) {
  tep_session_register('language');
  tep_session_register('languages_id');
}

$language = tep_get_languages_directory($HTTP_GET_VARS['language']);
if (!$language) $language = tep_get_languages_directory(DEFAULT_LANGUAGE);
 }

// include the language translations
 require(DIR_WS_LANGUAGES . $language . '.php');
 $current_page = split('\?', basename($PHP_SELF)); $current_page = $current_page[0]; // for BadBlue(Win32) webserver compatibility
 if (file_exists(DIR_WS_LANGUAGES . $language . '/' . $current_page)) {
include(DIR_WS_LANGUAGES . $language . '/' . $current_page);
 }

// define our general functions used application-wide
 require(DIR_WS_FUNCTIONS . 'general.php');
 require(DIR_WS_FUNCTIONS . 'html_output.php');

// define our localization functions
 require(DIR_WS_FUNCTIONS . 'localization.php');

// setup our boxes
 require(DIR_WS_CLASSES . 'table_block.php');
 require(DIR_WS_CLASSES . 'box.php');

// initialize the message stack for output messages
 require(DIR_WS_CLASSES . 'message_stack.php');
 $messageStack = new messageStack;

// split-page-results
 require(DIR_WS_CLASSES . 'split_page_results.php');

// entry/item info classes
 require(DIR_WS_CLASSES . 'object_info.php');

// email classes
 require(DIR_WS_CLASSES . 'mime.php');
 require(DIR_WS_CLASSES . 'email.php');

// calculate category path
 $cPath = $HTTP_GET_VARS['cPath'];
 if (strlen($cPath) > 0) {
$cPath_array = explode('_', $cPath);
$current_category_id = $cPath_array[(sizeof($cPath_array)-1)];
 } else {
$current_category_id = 0;
 }

// default open navigation box
 if (!tep_session_is_registered('selected_box')) {
tep_session_register('selected_box');
$selected_box = 'configuration';
 }
 if ($HTTP_GET_VARS['selected_box']) {
$selected_box = $HTTP_GET_VARS['selected_box'];
 }

// the following cache blocks are used in the Tools->Cache section
// ('language' in the filename is automatically replaced by available languages)
 $cache_blocks = array(array('title' => TEXT_CACHE_CATEGORIES, 'code' => 'categories', 'file' => 'categories_box-language.cache', 'multiple' => true),
					array('title' => TEXT_CACHE_MANUFACTURERS, 'code' => 'manufacturers', 'file' => 'manufacturers_box-language.cache', 'multiple' => true),
					array('title' => TEXT_CACHE_ALSO_PURCHASED, 'code' => 'also_purchased', 'file' => 'also_purchased-language.cache', 'multiple' => true)
				   );

// check if a default currency is set
 if (!defined('DEFAULT_CURRENCY')) {
$messageStack->add(ERROR_NO_DEFAULT_CURRENCY_DEFINED, 'error');
 }

// check if a default language is set
 if (!defined('DEFAULT_LANGUAGE')) {
$messageStack->add(ERROR_NO_DEFAULT_LANGUAGE_DEFINED, 'error');
 }
?>

Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Link to comment
Share on other sites

here is my /admin/includes/funtions/general.php Part 1

 

<?php
/*
 $Id: general.php,v 1.160 2003/07/12 08:32:47 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

////
// Redirect to another page or site
 function tep_redirect($url) {
global $logger;

if ( (strstr($url, "\n") != false) || (strstr($url, "\r") != false) ) {
  tep_redirect(tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false));
}

header('Location: ' . $url);

if (STORE_PAGE_PARSE_TIME == 'true') {
  if (!is_object($logger)) $logger = new logger;
  $logger->timer_stop();
}

exit;
 }

////
// Parse the data used in the html tags to ensure the tags will not break
 function tep_parse_input_field_data($data, $parse) {
return strtr(trim($data), $parse);
 }

 function tep_output_string($string, $translate = false, $protected = false) {
if ($protected == true) {
  return htmlspecialchars($string);
} else {
  if ($translate == false) {
	return tep_parse_input_field_data($string, array('"' => '"'));
  } else {
	return tep_parse_input_field_data($string, $translate);
  }
}
 }

 function tep_output_string_protected($string) {
return tep_output_string($string, false, true);
 }

 function tep_sanitize_string($string) {
$string = ereg_replace(' +', ' ', $string);

return preg_replace("/[<>]/", '_', $string);
 }

 function tep_customers_name($customers_id) {
$customers = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
$customers_values = tep_db_fetch_array($customers);

return $customers_values['customers_firstname'] . ' ' . $customers_values['customers_lastname'];
 }

 function tep_get_path($current_category_id = '') {
global $cPath_array;

if ($current_category_id == '') {
  $cPath_new = implode('_', $cPath_array);
} else {
  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 = '" . (int)$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 = '" . (int)$current_category_id . "'");
	$current_category = tep_db_fetch_array($current_category_query);

	if ($last_category['parent_id'] == $current_category['parent_id']) {
	  for ($i = 0, $n = sizeof($cPath_array) - 1; $i < $n; $i++) {
		$cPath_new .= '_' . $cPath_array[$i];
	  }
	} else {
	  for ($i = 0, $n = sizeof($cPath_array); $i < $n; $i++) {
		$cPath_new .= '_' . $cPath_array[$i];
	  }
	}

	$cPath_new .= '_' . $current_category_id;

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

return 'cPath=' . $cPath_new;
 }

 function tep_get_all_get_params($exclude_array = '') {
global $HTTP_GET_VARS;

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

$get_url = '';

reset($HTTP_GET_VARS);
while (list($key, $value) = each($HTTP_GET_VARS)) {
  if (($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array))) $get_url .= $key . '=' . $value . '&';
}

return $get_url;
 }

 function tep_date_long($raw_date) {
if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false;

$year = (int)substr($raw_date, 0, 4);
$month = (int)substr($raw_date, 5, 2);
$day = (int)substr($raw_date, 8, 2);
$hour = (int)substr($raw_date, 11, 2);
$minute = (int)substr($raw_date, 14, 2);
$second = (int)substr($raw_date, 17, 2);

return strftime(DATE_FORMAT_LONG, mktime($hour, $minute, $second, $month, $day, $year));
 }

////
// Output a raw date string in the selected locale date format
// $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS
// NOTE: Includes a workaround for dates before 01/01/1970 that fail on windows servers
 function tep_date_short($raw_date) {
if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false;

$year = substr($raw_date, 0, 4);
$month = (int)substr($raw_date, 5, 2);
$day = (int)substr($raw_date, 8, 2);
$hour = (int)substr($raw_date, 11, 2);
$minute = (int)substr($raw_date, 14, 2);
$second = (int)substr($raw_date, 17, 2);

if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) {
  return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
} else {
  return ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)));
}

 }

 function tep_datetime_short($raw_datetime) {
if ( ($raw_datetime == '0000-00-00 00:00:00') || ($raw_datetime == '') ) return false;

$year = (int)substr($raw_datetime, 0, 4);
$month = (int)substr($raw_datetime, 5, 2);
$day = (int)substr($raw_datetime, 8, 2);
$hour = (int)substr($raw_datetime, 11, 2);
$minute = (int)substr($raw_datetime, 14, 2);
$second = (int)substr($raw_datetime, 17, 2);

return strftime(DATE_TIME_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
 }

 function tep_get_category_tree($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false) {
global $languages_id;

if (!is_array($category_tree_array)) $category_tree_array = array();
if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => TEXT_TOP);

if ($include_itself) {
  $category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.language_id = '" . (int)$languages_id . "' and cd.categories_id = '" . (int)$parent_id . "'");
  $category = tep_db_fetch_array($category_query);
  $category_tree_array[] = array('id' => $parent_id, 'text' => $category['categories_name']);
}

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "' order by c.sort_order, cd.categories_name");
while ($categories = tep_db_fetch_array($categories_query)) {
  if ($exclude != $categories['categories_id']) $category_tree_array[] = array('id' => $categories['categories_id'], 'text' => $spacing . $categories['categories_name']);
  $category_tree_array = tep_get_category_tree($categories['categories_id'], $spacing . '   ', $exclude, $category_tree_array);
}

return $category_tree_array;
 }

 function tep_draw_products_pull_down($name, $parameters = '', $exclude = '') {
global $currencies, $languages_id;

if ($exclude == '') {
  $exclude = array();
}

$select_string = '<select name="' . $name . '"';

if ($parameters) {
  $select_string .= ' ' . $parameters;
}

$select_string .= '>';

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by products_name");
while ($products = tep_db_fetch_array($products_query)) {
  if (!in_array($products['products_id'], $exclude)) {
	$select_string .= '<option value="' . $products['products_id'] . '">' . $products['products_name'] . ' (' . $currencies->format($products['products_price']) . ')</option>';
  }
}

$select_string .= '</select>';

return $select_string;
 }

 function tep_options_name($options_id) {
global $languages_id;

$options = tep_db_query("select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$options_id . "' and language_id = '" . (int)$languages_id . "'");
$options_values = tep_db_fetch_array($options);

return $options_values['products_options_name'];
 }

 function tep_values_name($values_id) {
global $languages_id;

$values = tep_db_query("select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$values_id . "' and language_id = '" . (int)$languages_id . "'");
$values_values = tep_db_fetch_array($values);

return $values_values['products_options_values_name'];
 }

 function tep_info_image($image, $alt, $width = '', $height = '') {
if (tep_not_null($image) && (file_exists(DIR_FS_CATALOG_IMAGES . $image)) ) {
  $image = tep_image(DIR_WS_CATALOG_IMAGES . $image, $alt, $width, $height);
} else {
  $image = TEXT_IMAGE_NONEXISTENT;
}

return $image;
 }

 function tep_break_string($string, $len, $break_char = '-') {
$l = 0;
$output = '';
for ($i=0, $n=strlen($string); $i<$n; $i++) {
  $char = substr($string, $i, 1);
  if ($char != ' ') {
	$l++;
  } else {
	$l = 0;
  }
  if ($l > $len) {
	$l = 1;
	$output .= $break_char;
  }
  $output .= $char;
}

return $output;
 }

 function tep_get_country_name($country_id) {
$country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$country_id . "'");

if (!tep_db_num_rows($country_query)) {
  return $country_id;
} else {
  $country = tep_db_fetch_array($country_query);
  return $country['countries_name'];
}
 }

 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 = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'");
if (tep_db_num_rows($zone_query)) {
  $zone = tep_db_fetch_array($zone_query);
  return $zone['zone_name'];
} else {
  return $default_zone;
}
 }

 function tep_not_null($value) {
if (is_array($value)) {
  if (sizeof($value) > 0) {
	return true;
  } else {
	return false;
  }
} else {
  if ( (is_string($value) || is_int($value)) && ($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) {
	return true;
  } else {
	return false;
  }
}
 }

 function tep_browser_detect($component) {
global $HTTP_USER_AGENT;

return stristr($HTTP_USER_AGENT, $component);
 }

 function tep_tax_classes_pull_down($parameters, $selected = '') {
$select_string = '<select ' . $parameters . '>';
$classes_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
while ($classes = tep_db_fetch_array($classes_query)) {
  $select_string .= '<option value="' . $classes['tax_class_id'] . '"';
  if ($selected == $classes['tax_class_id']) $select_string .= ' SELECTED';
  $select_string .= '>' . $classes['tax_class_title'] . '</option>';
}
$select_string .= '</select>';

return $select_string;
 }

 function tep_geo_zones_pull_down($parameters, $selected = '') {
$select_string = '<select ' . $parameters . '>';
$zones_query = tep_db_query("select geo_zone_id, geo_zone_name from " . TABLE_GEO_ZONES . " order by geo_zone_name");
while ($zones = tep_db_fetch_array($zones_query)) {
  $select_string .= '<option value="' . $zones['geo_zone_id'] . '"';
  if ($selected == $zones['geo_zone_id']) $select_string .= ' SELECTED';
  $select_string .= '>' . $zones['geo_zone_name'] . '</option>';
}
$select_string .= '</select>';

return $select_string;
 }

 function tep_get_geo_zone_name($geo_zone_id) {
$zones_query = tep_db_query("select geo_zone_name from " . TABLE_GEO_ZONES . " where geo_zone_id = '" . (int)$geo_zone_id . "'");

if (!tep_db_num_rows($zones_query)) {
  $geo_zone_name = $geo_zone_id;
} else {
  $zones = tep_db_fetch_array($zones_query);
  $geo_zone_name = $zones['geo_zone_name'];
}

return $geo_zone_name;
 }

 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 = '" . (int)$address_format_id . "'");
$address_format = tep_db_fetch_array($address_format_query);

$company = tep_output_string_protected($address['company']);
if (isset($address['firstname']) && tep_not_null($address['firstname'])) {
  $firstname = tep_output_string_protected($address['firstname']);
  $lastname = tep_output_string_protected($address['lastname']);
} elseif (isset($address['name']) && tep_not_null($address['name'])) {
  $firstname = tep_output_string_protected($address['name']);
  $lastname = '';
} else {
  $firstname = '';
  $lastname = '';
}
$street = tep_output_string_protected($address['street_address']);
$suburb = tep_output_string_protected($address['suburb']);
$city = tep_output_string_protected($address['city']);
$state = tep_output_string_protected($address['state']);
if (isset($address['country_id']) && tep_not_null($address['country_id'])) {
  $country = tep_get_country_name($address['country_id']);

  if (isset($address['zone_id']) && tep_not_null($address['zone_id'])) {
	$state = tep_get_zone_code($address['country_id'], $address['zone_id'], $state);
  }
} elseif (isset($address['country']) && tep_not_null($address['country'])) {
  $country = tep_output_string_protected($address['country']);
} else {
  $country = '';
}
$postcode = tep_output_string_protected($address['postcode']);
$zip = $postcode;

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 ($country == '') $country = tep_output_string_protected($address['country']);
if ($state != '') $statecomma = $state . ', ';

$fmt = $address_format['format'];
eval("\$address = \"$fmt\";");

if ( (ACCOUNT_COMPANY == 'true') && (tep_not_null($company)) ) {
  $address = $company . $cr . $address;
}

return $address;
 }

 ////////////////////////////////////////////////////////////////////////////////////////////////
 //
 // Function	: tep_get_zone_code
 //
 // Arguments   : country		   country code string
 //			   zone			  state/province zone_id
 //			   def_state		 default string if zone==0
 //
 // Return	  : state_prov_code   state/province code
 //
 // Description : Function to retrieve the state/province code (as in FL for Florida etc)
 //
 ////////////////////////////////////////////////////////////////////////////////////////////////
 function tep_get_zone_code($country, $zone, $def_state) {

$state_prov_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and zone_id = '" . (int)$zone . "'");

if (!tep_db_num_rows($state_prov_query)) {
  $state_prov_code = $def_state;
}
else {
  $state_prov_values = tep_db_fetch_array($state_prov_query);
  $state_prov_code = $state_prov_values['zone_code'];
}

return $state_prov_code;
 }

 function tep_get_uprid($prid, $params) {
$uprid = $prid;
if ( (is_array($params)) && (!strstr($prid, '{')) ) {
  while (list($option, $value) = each($params)) {
	$uprid = $uprid . '{' . $option . '}' . $value;
  }
}

return $uprid;
 }

 function tep_get_prid($uprid) {
$pieces = explode('{', $uprid);

return $pieces[0];
 }

 function tep_get_languages() {
$languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");
while ($languages = tep_db_fetch_array($languages_query)) {
  $languages_array[] = array('id' => $languages['languages_id'],
							 'name' => $languages['name'],
							 'code' => $languages['code'],
							 'image' => $languages['image'],
							 'directory' => $languages['directory']);
}

return $languages_array;
 }

 function tep_get_category_name($category_id, $language_id) {
$category_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "' and language_id = '" . (int)$language_id . "'");
$category = tep_db_fetch_array($category_query);

return $category['categories_name'];
 }

 function tep_get_orders_status_name($orders_status_id, $language_id = '') {
global $languages_id;

if (!$language_id) $language_id = $languages_id;
$orders_status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . (int)$orders_status_id . "' and language_id = '" . (int)$language_id . "'");
$orders_status = tep_db_fetch_array($orders_status_query);

return $orders_status['orders_status_name'];
 }

 function tep_get_orders_status() {
global $languages_id;

$orders_status_array = array();
$orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "' order by orders_status_id");
while ($orders_status = tep_db_fetch_array($orders_status_query)) {
  $orders_status_array[] = array('id' => $orders_status['orders_status_id'],
								 'text' => $orders_status['orders_status_name']);
}

return $orders_status_array;
 }

 function tep_get_products_name($product_id, $language_id = 0) {
global $languages_id;

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

return $product['products_name'];
 }

 function tep_get_products_description($product_id, $language_id) {
$product_query = tep_db_query("select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
$product = tep_db_fetch_array($product_query);

return $product['products_description'];
 }

 function tep_get_products_url($product_id, $language_id) {
$product_query = tep_db_query("select products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
$product = tep_db_fetch_array($product_query);

return $product['products_url'];
 }

////
// Return the manufacturers URL in the needed language
// TABLES: manufacturers_info
 function tep_get_manufacturer_url($manufacturer_id, $language_id) {
$manufacturer_query = tep_db_query("select manufacturers_url from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int)$manufacturer_id . "' and languages_id = '" . (int)$language_id . "'");
$manufacturer = tep_db_fetch_array($manufacturer_query);

return $manufacturer['manufacturers_url'];
 }

////
// Wrapper for class_exists() function
// This function is not available in all PHP versions so we test it before using it.
 function tep_class_exists($class_name) {
if (function_exists('class_exists')) {
  return class_exists($class_name);
} else {
  return true;
}
 }

////
// Count how many products exist in a category
// TABLES: products, products_to_categories, categories
 function tep_products_in_category_count($categories_id, $include_deactivated = false) {
$products_count = 0;

if ($include_deactivated) {
  $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 = '" . (int)$categories_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 = '" . (int)$categories_id . "'");
}

$products = tep_db_fetch_array($products_query);

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

$childs_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$categories_id . "'");
if (tep_db_num_rows($childs_query)) {
  while ($childs = tep_db_fetch_array($childs_query)) {
	$products_count += tep_products_in_category_count($childs['categories_id'], $include_deactivated);
  }
}

return $products_count;
 }

////
// Count how many subcategories exist in a category
// TABLES: categories
 function tep_childs_in_category_count($categories_id) {
$categories_count = 0;

$categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$categories_id . "'");
while ($categories = tep_db_fetch_array($categories_query)) {
  $categories_count++;
  $categories_count += tep_childs_in_category_count($categories['categories_id']);
}

return $categories_count;
 }

////
// Returns an array with countries
// TABLES: countries
 function tep_get_countries($default = '') {
$countries_array = array();
if ($default) {
  $countries_array[] = array('id' => '',
							 'text' => $default);
}
$countries_query = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " order by countries_name");
while ($countries = tep_db_fetch_array($countries_query)) {
  $countries_array[] = array('id' => $countries['countries_id'],
							 'text' => $countries['countries_name']);
}

return $countries_array;
 }

////
// return an array with country zones
 function tep_get_country_zones($country_id) {
$zones_array = array();
$zones_query = tep_db_query("select zone_id, zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' order by zone_name");
while ($zones = tep_db_fetch_array($zones_query)) {
  $zones_array[] = array('id' => $zones['zone_id'],
						 'text' => $zones['zone_name']);
}

return $zones_array;
 }

 function tep_prepare_country_zones_pull_down($country_id = '') {
// preset the width of the drop-down for Netscape
$pre = '';
if ( (!tep_browser_detect('MSIE')) && (tep_browser_detect('Mozilla/4')) ) {
  for ($i=0; $i<45; $i++) $pre .= ' ';
}

$zones = tep_get_country_zones($country_id);

if (sizeof($zones) > 0) {
  $zones_select = array(array('id' => '', 'text' => PLEASE_SELECT));
  $zones = array_merge($zones_select, $zones);
} else {
  $zones = array(array('id' => '', 'text' => TYPE_BELOW));
// create dummy options for Netscape to preset the height of the drop-down
  if ( (!tep_browser_detect('MSIE')) && (tep_browser_detect('Mozilla/4')) ) {
	for ($i=0; $i<9; $i++) {
	  $zones[] = array('id' => '', 'text' => $pre);
	}
  }
}

return $zones;
 }

////
// Get list of address_format_id's
 function tep_get_address_formats() {
$address_format_query = tep_db_query("select address_format_id from " . TABLE_ADDRESS_FORMAT . " order by address_format_id");
$address_format_array = array();
while ($address_format_values = tep_db_fetch_array($address_format_query)) {
  $address_format_array[] = array('id' => $address_format_values['address_format_id'],
								  'text' => $address_format_values['address_format_id']);
}
return $address_format_array;
 }

////
// Alias function for Store configuration values in the Administration Tool
 function tep_cfg_pull_down_country_list($country_id) {
return tep_draw_pull_down_menu('configuration_value', tep_get_countries(), $country_id);
 }

 function tep_cfg_pull_down_zone_list($zone_id) {
return tep_draw_pull_down_menu('configuration_value', tep_get_country_zones(STORE_COUNTRY), $zone_id);
 }

 function tep_cfg_pull_down_tax_classes($tax_class_id, $key = '') {
$name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');

$tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
$tax_class_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
while ($tax_class = tep_db_fetch_array($tax_class_query)) {
  $tax_class_array[] = array('id' => $tax_class['tax_class_id'],
							 'text' => $tax_class['tax_class_title']);
}

return tep_draw_pull_down_menu($name, $tax_class_array, $tax_class_id);
 }

Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...