Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Abstract Zones


Guest

Recommended Posts

Function tep_get_cat_zone_name is missing from the documentation. Item 3 should read:

 

I have updated this to my general.php file, but I now get

Parse error: syntax error, unexpected T_VARIABLE in /home/glitter/public_html/ggear-bk/admin/includes/functions/general.php on line 1439

on line

 

   $zone_query = tep_db_query("select cat_zone_name from " . TABLE_CAT_ZONES . " where cat_zone_id = '" . (int)$cat_zone_id . "'");

 

 

This is the entire Abstract Zones peice from general.php

 

 

//-MS Active Shipping Added

 

function tep_cfg_pull_down_active_zones($zone_id, $key = '') {

 

$name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');

 

 

 

$zone_array = array(array('id' => '0', 'text' => TEXT_NONE));

 

$zone_query = tep_db_query("select cat_zone_id, cat_zone_name from " . TABLE_CAT_ZONES . " order by cat_zone_name");

 

 

 

while ($zone = tep_db_fetch_array($zone_query)) {

 

$zone_array[] = array('id' => $zone['cat_zone_id'],

 

'text' => $zone['cat_zone_name']);

 

}

 

return tep_draw_pull_down_menu($name, $zone_array, $zone_id);

 

}

 

 

 

function tep_get_active_zone_title($zone_id) {

 

if ($zone_id == '0') {

 

return TEXT_NONE;

 

} else {

 

$zone_query = tep_db_query("select cat_zone_name from " . TABLE_CAT_ZONES . " where cat_zone_id = '" . (int)$zone_id . "'");

 

$zone = tep_db_fetch_array($zone_query);

 

 

 

return $zone['cat_zone_name'];

 

}

 

}

function tep_get_cat_zone_name($cat_zone_id, $default_zone = 'Unknown Zone') {

 

   $zone_query = tep_db_query("select cat_zone_name from " . TABLE_CAT_ZONES . " where cat_zone_id = '" . (int)$cat_zone_id . "'");

   

 if (tep_db_num_rows($zone_query)) {

 

      $zone = tep_db_fetch_array($zone_query);

 

      return $zone['cat_zone_name'];

 

    } else {

 

      return $default_zone;

 

    }

 

  }

 

//-MS Active Shipping Added EOM

Link to comment
Share on other sites

I have updated this to my general.php file, but I now get

Parse error: syntax error, unexpected T_VARIABLE in /home/glitter/public_html/ggear-bk/admin/includes/functions/general.php on line 1439

on line

 

   $zone_query = tep_db_query("select cat_zone_name from " . TABLE_CAT_ZONES . " where cat_zone_id = '" . (int)$cat_zone_id . "'");

what kind of editor are you using? I see these double blank lines which indicate the old osc file manager. If so restore your file(s) from backup and re-do the installation using a regular editor.

 

And the entire section should go in the general.php before the final

?>

line.

Link to comment
Share on other sites

what kind of editor are you using? I see these double blank lines which indicate the old osc file manager. If so restore your file(s) from backup and re-do the installation using a regular editor.

 

And the entire section should go in the general.php before the final

?>

line.

 

Actually am using BBEDIT, os not using any OSC file manager.

I first copied and paste the entire section from the posting into my file using BBEDIT and I got a similar error on the first line

 

function tep_cfg_pull_down_active_zones($zone_id, $key = '') {

$name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');

 

This was when I did not have a blank line between each. Then I changed it back to my first implementation of the contribution which had the blank line between each, as follows

 

function tep_cfg_pull_down_active_zones($zone_id, $key = '') {

 

$name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');

 

 

and the error now moved back to the last function as I indicated in my posting. I added extra blank lines in myself to see if that was the problem, but it didnt change it. I hope that isnt too confusing.

 

Mandi

Link to comment
Share on other sites

Actually am using BBEDIT, os not using any OSC file manager.

I first copied and paste the entire section from the posting into my file using BBEDIT and I got a similar error on the first line

 

I figured it out, it was the copy and paste from the post that caused the error. I looked at the file with wordpad and could see strange special characters for spaces in the file, removed these and all was good.

 

thanks

Link to comment
Share on other sites

if you can indulge me just a wee bit as I normally try and figure these things out myself but due to time constraints I would like to ask.

 

I am looking to use this contribution so that I can restrict the sale of a downloadable product to international customers only. (because the product is not available to local customers due to local laws).

 

I am a bit confused on how I will be able to do this with the contribution although I believe it will do the job.

 

I have created a new shipping zone and added a product to it, I have modified the flat rate shipping module, but I am a bit unsure how close the deal and make the product available only to international customers, when i have flat rate available for both local and international customers

Link to comment
Share on other sites

if you can indulge me just a wee bit as I normally try and figure these things out myself but due to time constraints I would like to ask.

 

I am looking to use this contribution so that I can restrict the sale of a downloadable product to international customers only. (because the product is not available to local customers due to local laws).

 

I am a bit confused on how I will be able to do this with the contribution although I believe it will do the job.

 

I have created a new shipping zone and added a product to it, I have modified the flat rate shipping module, but I am a bit unsure how close the deal and make the product available only to international customers, when i have flat rate available for both local and international customers

 

 

Okay I have not got the contribution in and configured a Test Zone, I find that it probably will not do the job.

I need to be able to set a product to be only available to a certain shipping zone. So this means that at check out I need to be able to warn customers they cannot buy that product based on the shipping address or in the case of a downloadable item the billing address. I would guess with some modification this contribution could be used, if I do a check in check out pages of the abstract zone and if the product is not in this zone then I warn and remove it from the cart. However, that may take me a while to figure out how to do. Has anyone done such a thing, I have searched but cannot find a similar contribution.

 

thanks

Link to comment
Share on other sites

  • 2 weeks later...

Hi Mark

 

Thanks for the link to this contribution, it's great.

 

I'm a bit stuck on getting it working fully and wondered if you could point me in the right direction please.

 

Products are either

1. Buyer to Pickup

or

2. Individual Shipping Prices or Buyer to Pickup as selected by the buyer.

 

I've created two shipping zones:

1. Collect - contains only products that are Buyer to Pickup

2. Collect/Individual Prices - contains products buyer to choose shipping option

 

Shipping modules installed:

1. individual prices

2. pickup

3. pickupi (a duplicate of pickup to use)

 

I've then set up:

- pickup - Collect - exclusive

- pickupi - Collect/Individual Prices - inclusive

- individual prices - Collect/Individual Prices - inclusive

 

Two of three buyer cart options work perfectly, but the last one doesn't and I really don't understand why:

- Product(s) in cart from Collect zone gives buyer pickup option only - perfect

- Products in cart from Collect and Collect/Individual Prices zones gives buyer individual prices and pickupi - perfect (the exclusive setting on pickup ensures this option is not included to give the buyer two pickup options)

- Product(s) in cart from Collect/Individual Prices zone gives the buyer individual prices option only but it should give individual prices and pickupi

 

I've been looking at this for some time now and can't see where I've gone wrong. I'd be very grateful for help.

 

Many thanks

Katie

Link to comment
Share on other sites

not sure I understand this:

 

First place different products in the 2 different shipping zones to make sure what you try to do is possible

 

Collect/Individual Prices is a shipping zone ok

 

The "individual prices" shipping module handles the "Collect/Individual Prices" in inclusive mode.

 

Then if products from the "Collect/Individual Prices" zone are in the cart the "individual prices" shipping module should show up with all options. Same thing will happen with the "pickupi" shipping module so both modules and their options should show up during checkout_shipping

 

Can you post the shipping modules code here? (make sure the duplicated module you've made, looks like a different module alltogether, cuz just one common definition is enough to mix up the modules)

Link to comment
Share on other sites

not sure I understand this:

 

First place different products in the 2 different shipping zones to make sure what you try to do is possible

 

Collect/Individual Prices is a shipping zone ok

 

The "individual prices" shipping module handles the "Collect/Individual Prices" in inclusive mode.

 

Then if products from the "Collect/Individual Prices" zone are in the cart the "individual prices" shipping module should show up with all options. Same thing will happen with the "pickupi" shipping module so both modules and their options should show up during checkout_shipping

 

Can you post the shipping modules code here? (make sure the duplicated module you've made, looks like a different module alltogether, cuz just one common definition is enough to mix up the modules)

 

 

Hi Mark,

 

Thanks for getting back to me so quickly, here goes the code:

 

Shipping Module: pickup

<?php
/*
 $Id: pickup.php,v 1.40 2003/02/05 22:41:52 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class pickup {
var $code, $title, $description, $icon, $enabled;

// class constructor
function pickup() {
  global $order;

  $this->code = 'pickup';
  $this->title = MODULE_SHIPPING_PICKUP_TEXT_TITLE;
  $this->description = MODULE_SHIPPING_PICKUP_TEXT_DESCRIPTION;
  $this->sort_order = MODULE_SHIPPING_PICKUP_SORT_ORDER;
  $this->icon = '';
  $this->tax_class = MODULE_SHIPPING_PICKUP_TAX_CLASS;
  $this->enabled = ((MODULE_SHIPPING_PICKUP_STATUS == 'True') ? true : false);

  if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_PICKUP_ZONE > 0) ) {
	$check_flag = false;
	$check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_PICKUP_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
	while ($check = tep_db_fetch_array($check_query)) {
	  if ($check['zone_id'] < 1) {
		$check_flag = true;
		break;
	  } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
		$check_flag = true;
		break;
	  }
	}

	if ($check_flag == false) {
	  $this->enabled = false;
	}
  }
  //-MS- Active Shipping Added
  if( $this->enabled == true && function_exists('tep_check_active_zone') ) {
	$this->enabled = tep_check_active_zone(MODULE_SHIPPING_PICKUP_ACTIVE_ZONE, MODULE_SHIPPING_PICKUP_ACTIVE_MODE);
  }
//-MS- Active Shipping Added EOM
}

// class methods
function quote($method = '') {
  global $order;

  $this->quotes = array('id' => $this->code,
						'module' => MODULE_SHIPPING_PICKUP_TEXT_TITLE,
						'methods' => array(array('id' => $this->code,
												 'title' => MODULE_SHIPPING_PICKUP_TEXT_WAY,
												 'cost' => MODULE_SHIPPING_PICKUP_COST)));

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

  if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);

  return $this->quotes;
}

function check() {
  if (!isset($this->_check)) {
	$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_PICKUP_STATUS'");
	$this->_check = tep_db_num_rows($check_query);
  }
  return $this->_check;
}

function install() {
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Customer Pickup', 'MODULE_SHIPPING_PICKUP_STATUS', 'True', 'Do you want to offer customer pickup?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Pickup Fee', 'MODULE_SHIPPING_PICKUP_COST', '0.00', 'The fee for all orders being picked up by the customer. Most likely will be 0.00 but can be changed if needed.', '6', '0', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_PICKUP_TAX_CLASS', '0', 'Use the following tax class on the fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_PICKUP_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
  //-MS- Active Shipping Added
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Active Shipping', 'MODULE_SHIPPING_PICKUP_ACTIVE_ZONE', '0', 'Use the following active zone to activate the module based on categories-products.', '6', '0', 'tep_get_active_zone_title', 'tep_cfg_pull_down_active_zones(', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Mode of Operation', 'MODULE_SHIPPING_PICKUP_ACTIVE_MODE', 'Inclusive', 'Inclusive: Enables the module if one product is found to be covered by the active zone.<br>Exclusive: Enables the module if all products in the cart are covered by the active zone', '6', '0', 'tep_cfg_select_option(array(\'Inclusive\', \'Exclusive\'), ', now())");
//-MS- Active Shipping Added EOM
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_PICKUP_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
}

function remove() {
  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}

function keys() {
//-MS- Active Shipping Added
  return array('MODULE_SHIPPING_PICKUP_STATUS', 'MODULE_SHIPPING_PICKUP_COST', 'MODULE_SHIPPING_PICKUP_TAX_CLASS', 'MODULE_SHIPPING_PICKUP_ZONE', 'MODULE_SHIPPING_PICKUP_ACTIVE_ZONE', 'MODULE_SHIPPING_PICKUP_ACTIVE_MODE', 'MODULE_SHIPPING_PICKUP_SORT_ORDER');
  //-MS- Active Shipping Added EOM
}
 }
?>

 

and

 

Shipping Module: pickupi

<?php
/*
 $Id: pickupis.php,v 1.40 2003/02/05 22:41:52 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class pickupis {
var $code, $title, $description, $icon, $enabled;

// class constructor
function pickupis() {
  global $order;

  $this->code = 'pickupis';
  $this->title = MODULE_SHIPPING_PICKUPIS_TEXT_TITLE;
  $this->description = MODULE_SHIPPING_PICKUPIS_TEXT_DESCRIPTION;
  $this->sort_order = MODULE_SHIPPING_PICKUPIS_SORT_ORDER;
  $this->icon = '';
  $this->tax_class = MODULE_SHIPPING_PICKUPIS_TAX_CLASS;
  $this->enabled = ((MODULE_SHIPPING_PICKUPIS_STATUS == 'True') ? true : false);

  if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_PICKUPIS_ZONE > 0) ) {
	$check_flag = false;
	$check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_PICKUPIS_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
	while ($check = tep_db_fetch_array($check_query)) {
	  if ($check['zone_id'] < 1) {
		$check_flag = true;
		break;
	  } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
		$check_flag = true;
		break;
	  }
	}

	if ($check_flag == false) {
	  $this->enabled = false;
	}
  }
  //-MS- Active Shipping Added
  if( $this->enabled == true && function_exists('tep_check_active_zone') ) {
	$this->enabled = tep_check_active_zone(MODULE_SHIPPING_PICKUPIS_ACTIVE_ZONE, MODULE_SHIPPING_PICKUPIS_ACTIVE_MODE);
  }
//-MS- Active Shipping Added EOM

}

// class methods
function quote($method = '') {
  global $order;

  $this->quotes = array('id' => $this->code,
						'module' => MODULE_SHIPPING_PICKUPIS_TEXT_TITLE,
						'methods' => array(array('id' => $this->code,
												 'title' => MODULE_SHIPPING_PICKUPIS_TEXT_WAY,
												 'cost' => MODULE_SHIPPING_PICKUPIS_COST)));

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

  if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);

  return $this->quotes;
}

function check() {
  if (!isset($this->_check)) {
	$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_PICKUPIS_STATUS'");
	$this->_check = tep_db_num_rows($check_query);
  }
  return $this->_check;
}

function install() {
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Customer Pickup', 'MODULE_SHIPPING_PICKUPIS_STATUS', 'True', 'Do you want to offer customer pickupis?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Pickup Fee', 'MODULE_SHIPPING_PICKUPIS_COST', '0.00', 'The fee for all orders being picked up by the customer. Most likely will be 0.00 but can be changed if needed.', '6', '0', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_PICKUPIS_TAX_CLASS', '0', 'Use the following tax class on the fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_PICKUPIS_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
  //-MS- Active Shipping Added
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Active Shipping', 'MODULE_SHIPPING_PICKUPIS_ACTIVE_ZONE', '0', 'Use the following active zone to activate the module based on categories-products.', '6', '0', 'tep_get_active_zone_title', 'tep_cfg_pull_down_active_zones(', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Mode of Operation', 'MODULE_SHIPPING_PICKUPIS_ACTIVE_MODE', 'Inclusive', 'Inclusive: Enables the module if one product is found to be covered by the active zone.<br>Exclusive: Enables the module if all products in the cart are covered by the active zone', '6', '0', 'tep_cfg_select_option(array(\'Inclusive\', \'Exclusive\'), ', now())");
//-MS- Active Shipping Added EOM
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_PICKUPIS_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
}

function remove() {
  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}

function keys() {
//-MS- Active Shipping Added
  return array('MODULE_SHIPPING_PICKUPIS_STATUS', 'MODULE_SHIPPING_PICKUPIS_COST', 'MODULE_SHIPPING_PICKUPIS_TAX_CLASS', 'MODULE_SHIPPING_PICKUPIS_ZONE', 'MODULE_SHIPPING_PICKUPIS_ACTIVE_ZONE', 'MODULE_SHIPPING_PICKUPIS_ACTIVE_MODE', 'MODULE_SHIPPING_PICKUPIS_SORT_ORDER');
  //-MS- Active Shipping Added EOM
}
 }
?>

 

I thought pickup and pickupi were correct because in some instances they are handled correctly.

 

As a test I changed Collect handled by pickup exclusive to inclusive and with a product from Collect and a product from Collect/Individual Prices in the cart individual prices, pickup and pickupi are shown.

 

Then if I change Collect handled by pickup back to exclusive with the same two products in the cart I have individual prices and pickupi available suggesting that the three shipping modules are correct (I hoped).

 

It's only when I take the Collect handled by pickup exclusive product out of the cart the problem occurs, with only an Individual Prices/Collect product handled by individual prices inclusive and pickupi inclusive in the cart, only individual prices is available when it should be individual prices and pickupi.

 

Sorry this is a bit complicated, if it's easier if you have a look let me know and I'll PM you shop details (it's not live yet).

 

Many thanks for your help.

Katie

Link to comment
Share on other sites

goto your catalog\includes\functions\general.php locate this code and remove it:

 

	  if( !tep_not_null($catzone['categories_id']) && !tep_not_null($catzone['categories_id']) )
	return false;

that shouldn't be there in the first place. I don't know if that would cause this problem though.

 

then further down in the same function locate:

 

	foreach( $products_array as $key=>$val) {
  $check = in_array($val['id'], $key_array);

 

change it to:

	foreach( $products_array as $key=>$val) {
  $check = in_array((int)$val['id'], $key_array);

See if it makes a difference.

Link to comment
Share on other sites

See if it makes a difference.

 

Hi Mark,

 

No I'm afraid those changes make no difference it still treats each zone the same and doesn't show both shipping options for products in the Collect?Individual Prices zone.

 

Many thanks

Kate

Link to comment
Share on other sites

Hi Mark,

 

No I'm afraid those changes make no difference it still treats each zone the same and doesn't show both shipping options for products in the Collect?Individual Prices zone.

 

Many thanks

Kate

This happens cuz the osc shipping class is being patched. And that is really a bad hack because it causes problems to every shipping module installed. Try using the orginal class and test the abstract zones.

Link to comment
Share on other sites

I'm getting this error after trying to install the sql tables:

 

SQL query:

 

CREATE TABLE categories_to_cat_zones(

cat_zone_id int( 11 ) NOT NULL ,

categories_id int( 11 ) default NULL ,

products_id int( 11 ) default NULL ,

PRIMARY KEY ( cat_zone_id, categories_id, products_id )

) TYPE = MYISAM

 

MySQL said: Documentation

#1171 - All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead

 

What to do??

Link to comment
Share on other sites

I'm getting this error after trying to install the sql tables:

 

SQL query:

 

CREATE TABLE categories_to_cat_zones(

cat_zone_id int( 11 ) NOT NULL ,

categories_id int( 11 ) default NULL ,

products_id int( 11 ) default NULL ,

PRIMARY KEY ( cat_zone_id, categories_id, products_id )

) TYPE = MYISAM

 

MySQL said: Documentation

#1171 - All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead

 

What to do??

 

Try this:

 

CREATE TABLE categories_to_cat_zones(
cat_zone_id int( 11 ) NOT NULL ,
categories_id int( 11 ) NOT NULL ,
products_id int( 11 ) NOT NULL ,
PRIMARY KEY ( cat_zone_id, categories_id, products_id )
) TYPE = MYISAM

Link to comment
Share on other sites

Try this:

 

CREATE TABLE categories_to_cat_zones(
cat_zone_id int( 11 ) NOT NULL ,
categories_id int( 11 ) NOT NULL ,
products_id int( 11 ) NOT NULL ,
PRIMARY KEY ( cat_zone_id, categories_id, products_id )
) TYPE = MYISAM

That fixed it! Thank you, Mark!

Link to comment
Share on other sites

  • 1 month later...

Hello all! I'm fairly new to everything but can sometimes work my problems out. I installed the abstract zones contrib. and everything works fine except for when i go to my reports I get 2 errors.

 

--------------------------------- #1

Best Products Purchased

 

 

1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '*) as total from products p, products_description pd where pd.

 

select count(distinct *) as total from products p, products_description pd where pd.products_id = p.products_id and pd.language_id = '1' and p.products_ordered > 0

 

[TEP STOP]

 

 

---------------------------------#2

Best Customer Orders-Total

 

 

1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '*) as total from customers c, orders_products op, orders o whe

 

select count(distinct *) as total from customers c, orders_products op, orders o where c.customers_id = o.customers_id and o.orders_id = op.orders_id

 

[TEP STOP]

 

 

 

 

I just don't know where to start. If someone could help me out I'd really appreciate it :lol:

Link to comment
Share on other sites

Hello all! I'm fairly new to everything but can sometimes work my problems out. I installed the abstract zones contrib. and everything works fine except for when i go to my reports I get 2 errors.

 

--------------------------------- #1

Best Products Purchased

1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '*) as total from products p, products_description pd where pd.

 

select count(distinct *) as total from products p, products_description pd where pd.products_id = p.products_id and pd.language_id = '1' and p.products_ordered > 0

 

[TEP STOP]

---------------------------------#2

Best Customer Orders-Total

1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '*) as total from customers c, orders_products op, orders o whe

 

select count(distinct *) as total from customers c, orders_products op, orders o where c.customers_id = o.customers_id and o.orders_id = op.orders_id

 

[TEP STOP]

I just don't know where to start. If someone could help me out I'd really appreciate it :lol:

A couple of things you could do. You could modify the reports scripts those giving the sql errors to pass the extra parameter required for the distinct. Or you could extract the admin_page_results.php file from this contribution

http://www.oscommerce.com/community/contributions,5080

copy it over to your store should be in catalog\admin\includes\classes directory and replace all instances of splitPageResults with adminPageResults inside the catalog\admin\shipping_zones.php fille. Then at the beginning of this file just below

require('includes/application_top.php');

 

add

require(DIR_WS_CLASSES . 'admin_page_results.php');

 

This will be included with the next version.

Edited by enigma1
Link to comment
Share on other sites

  • 2 years later...

Hi I have this installed and working as far as I can tell but I have a problem. I have a few states we cannot ship to so when they go to checkout there are no shipping options which is correct but they can still checkout I need the items removed from their cart if they are in that zone so they cant checkout at all. Is this possible?

Link to comment
Share on other sites

  • 11 months later...

I think this contrib is exactly what I needed, though I'm having one problem:

 

I can't seem to implement it correctly with the Table Rate Shipping module.

 

I'm not getting any error messages.

 

The problem is, there are 2 new (empty) fields in the module now, but no indication of content.:

 

table-mod.png

 

I'm not sure if I did the implementation correctly. I basically took the code/instructions for the Flat Rate module, and just used the Table module and switched all the "FLAT" parts of the code to "TABLE".

 

 

Here's the code:

 

<?php
/*
 $Id: table.php,v 1.26x 2003/01/31 $

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

 Copyright (c) 2003 osCommerce

 * Modifications by Christian Lescuyer <[email protected]>
 * Copyright (c) 2003 Goélette http://www.goelette.net

 Released under the GNU General Public License
*/

 class table {
   var $code, $title, $description, $icon, $enabled;

// class constructor
   function table() {
     global $order;

     $this->code = 'table';
     $this->title = MODULE_SHIPPING_TABLE_TEXT_TITLE;
     $this->description = MODULE_SHIPPING_TABLE_TEXT_DESCRIPTION;
     $this->sort_order = MODULE_SHIPPING_TABLE_SORT_ORDER;
     $this->icon = '';
     $this->enabled = ((MODULE_SHIPPING_TABLE_STATUS == 'True') ? true : false);
     $this->tax_class = MODULE_SHIPPING_TABLE_TAX_CLASS;

     if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE_ZONE > 0) ) {
       $check_flag = false;
       $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLE_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
       while ($check = tep_db_fetch_array($check_query)) {
         if ($check['zone_id'] < 1) {
           $check_flag = true;
           break;
         } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
           $check_flag = true;
           break;
         }
       }

       if ($check_flag == false) {
         $this->enabled = false;
       }
     }
//-MS- Active Shipping Added
     if( $this->enabled == true && function_exists('tep_check_active_zone') ) {
       $this->enabled = tep_check_active_zone(MODULE_SHIPPING_TABLE_ACTIVE_ZONE, MODULE_SHIPPING_TABLE_ACTIVE_MODE);
     }
//-MS- Active Shipping Added EOM

   }

// class methods
   function quote($method = '') {
     global $cart, $shipping_weight, $shipping_num_boxes;

     if (MODULE_SHIPPING_TABLE_MODE == 'price') {
       $order_total = $cart->show_total();
     } else if (MODULE_SHIPPING_TABLE_MODE == 'count') {
       $order_total = $cart->count_contents();
     } else {
       $order_total = $shipping_weight;
     }

     $table_cost = split("[:,]" , MODULE_SHIPPING_TABLE_COST);
     $size = sizeof($table_cost);
     for ($i=0, $n=$size; $i<$n; $i+=2) {
       if ($order_total <= $table_cost[$i]) {
         $shipping = $table_cost[$i+1];
         break;
       }
     }

     if (MODULE_SHIPPING_TABLE_MODE == 'weight') {
       $shipping = $shipping * $shipping_num_boxes;
     }

     $this->quotes = array('id' => $this->code,
                           'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE,
                           'methods' => array(array('id' => $this->code,
                                                    'title' => MODULE_SHIPPING_TABLE_TEXT_WAY,
                                                    'cost' => $shipping + MODULE_SHIPPING_TABLE_HANDLING)));

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

     if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);

     return $this->quotes;
   }

   function check() {
     if (!isset($this->_check)) {
       $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_TABLE_STATUS'");
       $this->_check = tep_db_num_rows($check_query);
     }
     return $this->_check;
   }

   function install() {
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_TABLE_STATUS', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLE_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total weight, cost or number of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc', '6', '0', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Table Method', 'MODULE_SHIPPING_TABLE_MODE', 'weight', 'The shipping cost is based on the total weight, or the order total, or the number of items ordered.', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\', \'count\'), ', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_TABLE_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_TABLE_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");

//-MS- Active Shipping Added
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Active Shipping', 'MODULE_SHIPPING_TABLE_ACTIVE_ZONE', '0', 'Use the following active zone to activate the module based on categories-products.', '6', '0', 'tep_get_active_zone_title', 'tep_cfg_pull_down_active_zones(', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Mode of Operation', 'MODULE_SHIPPING_TABLE_ACTIVE_MODE', 'Inclusive', 'Inclusive: Enables the module if one product is found to be covered by the active zone.<br>Exclusive: Enables the module if all products in the cart are covered by the active zone', '6', '0', 'tep_cfg_select_option(array(\'Inclusive\', \'Exclusive\'), ', now())");
//-MS- Active Shipping Added EOM

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_SHIPPING_TABLE_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
     tep_db_query( "insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_TABLE_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())" );
   }

   function remove() {
     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
   }

   function keys() {
//-MS- Active Shipping Added
     return array('MODULE_SHIPPING_TABLE_STATUS', 'MODULE_SHIPPING_TABLE_COST', 'MODULE_SHIPPING_TABLE_TAX_CLASS', 'MODULE_SHIPPING_TABLE_ZONE', 'MODULE_SHIPPING_TABLE_ACTIVE_ZONE', 'MODULE_SHIPPING_TABLE_ACTIVE_MODE', 'MODULE_SHIPPING_TABLE_SORT_ORDER');
//-MS- Active Shipping Added EOM

   }
 }
?>

Link to comment
Share on other sites

However, I am having another issue:

 

(and sorry for all the extra posting--it wouldn't allow me to edit/update the previous post)

 

When it comes to checking out, the module doesn't work.

 

 

Here's what I'm trying to do:

 

There are certain items that are supposed to be shipped locally (or within a certain zone) only.

 

However, when those items are in the cart and I try to check out with a non-local shipping address, I am still able to checkout.

 

I want to restrict it so if someone outside of the local shipping zone tries to checkout one of the restricted shipping items, they won't be able to--there will be an error message or something.

 

Are there other settings that need to be changed?

Link to comment
Share on other sites

  • 1 month later...
  • 5 months later...

Hi Mark,

 

I hope you are well!

 

I have this working really well, at the moment I have 2 flat rate shipping modules setup as

 

Flat Rate 1 - £25.00

Flat Rate 2 - £4.95

 

The £25 delivery charge is for a washing machine and the £4.95 is say for a dvd.

 

Now if the customer adds a washing machine and a dvd to the shopping cart then the shipping page shows both delivery options.

 

Any ideas on how I would get around this so it would only show the higher delivery charge where there is enough markup in the higher value product to encompass the shipping cost of the dvd or if there is a better way to do it then I am open to your suggestions.

 

Regards

 

Mark

 

Hi, well i have a similar problem, what if i want to show the sum of the two values , or put multiple active shipping in one only module? any ideas on how i could do that... ?

 

Example

 

I have 3 categories

 

Bathroom - $10

Kitchen - $20

Forniture - $30

 

Now i want the shipping module show me the sum of 3 shipping cost categories

 

Shipping Cost = $60

 

Any ideas? thank you for your help!

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...