Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

shipping method trouble


Guest

Recommended Posts

Posted

Hi

 

I have got oscommerce 2.3.1 installed

 

I have two shipping methods, one is collection in person and the other is free uk delivery

 

When i select free uk delivery and click continue it works fine and goes to the checkout payment page

 

but when i select the collection in person option and click continue, i get this error

 

Deprecated: Function split() is deprecated in /customers/5/9/2/irhmedia.co.uk/httpd.www/includes/modules/shipping/collection.php on line 34 Deprecated: Function split() is deprecated in /customers/5/9/2/irhmedia.co.uk/httpd.www/includes/modules/shipping/collection.php on line 47 Warning: Cannot modify header information - headers already sent by (output started at /customers/5/9/2/irhmedia.co.uk/httpd.www/includes/modules/shipping/collection.php:34) in /customers/5/9/2/irhmedia.co.uk/httpd.www/includes/functions/general.php on line 45

 

Does anyone know how i can fix it please so it works

 

Thank you

 

Ian

Posted

How do I know what version of PHP i have

 

Thank you

 

Ian

Posted

I read the notes and just had to add the word preg in before the word split and it works perfect now

 

Just need to solve one tiny problem now

 

Dunno if you could help

 

I have got a 0 next to the word store pickup under the heading collection in person heading in checkout_shipping

 

if your in the uk add a product to the cart and get to the checkout shipping page and you see what i mean

 

Thank you for the link about the split function

 

Ian

Posted

Hi

 

I have gone though the coding from the collection.php file and can't see a "0" anywhere that shouldn't be there

 

I have pasted the code in below to see if you can see it in case I am missing it somewhere

 

<?php
/*   $Id: Collection In Person By Ben Doyle 02/11/2006
 Updated by Peter Batin (incorrect total weight was being calculated) 13/07/2008
 Rates: 0:0
 Limits Applied: 100.00Kg orders over this value will not be shown this method.
*/
 class collection {
   var $code, $title, $description, $enabled, $num_zones;
// class constructor
   function collection() {
global $order, $total_weight;
  $this->code = 'collection';
  $this->title = MODULE_SHIPPING_COLLECTION_TEXT_TITLE;
  $this->description = MODULE_SHIPPING_COLLECTION_TEXT_DESCRIPTION;
  $this->sort_order = MODULE_SHIPPING_COLLECTION_SORT_ORDER;
  $this->tax_class = MODULE_SHIPPING_COLLECTION_TAX_CLASS;
  $this->enabled = ((MODULE_SHIPPING_COLLECTION_STATUS == 'True') ? true : false);
  $this->num_zones = 1;

   }
// class methods
   function quote($method = '') {
global $order, $total_weight, $shipping_num_boxes;
  $dest_country = $order->delivery['country']['iso_code_2'];
  $dest_zone = 0;
  $error = false;
   if ($order->delivery['country']['iso_code_2'] == 'GB')  {  // Only UK Customers to see shipping method. Hide everbody else.
	  for ($i=1; $i<=$this->num_zones; $i++) {
	  $countries_table = constant('MODULE_SHIPPING_COLLECTION_COUNTRIES_' . $i);
	  $country_zones = preg_split("[,]", $countries_table);
	  if (in_array($dest_country, $country_zones)) {
	    $dest_zone = $i;
	    break;
	  }
    }
  if ($dest_zone == 0) {
    $error = true;
  } else {
    $shipping = -1;
    $zones_cost = constant('MODULE_SHIPPING_COLLECTION_COST_' . $dest_zone);
    $zones_table = preg_split("[:,]" , $zones_cost);
    $size = sizeof($zones_table);
    for ($i=0; $i<$size; $i+=2) {
	  if ($total_weight <= $zones_table[$i]) {
	    $shipping = $zones_table[$i+1];
  if(tep_not_null($method) )
  // Text shown on Checkout_Confirmation
  $shipping_method = ''; // Leaving this entry blank causes only the shipping title to show i.e Royal Mail 1st Class Rec   
  else
  // Text shown on Checkout_shipping -  Delivery Weight : 0.7 Kg's (Please Arrange Collection)
  $shipping_method = MODULE_SHIPPING_COLLECTION_TEXT_WAY .''. $total_weight .''. MODULE_SHIPPING_COLLECTION_TEXT_UNITS .''. MODULE_SHIPPING_COLLECTION_DELIVERY_TIMES;
  break;
	  }
    }
    if ($shipping == -1) {
	  $shipping_cost = 0;
	  $shipping_method = MODULE_SHIPPING_COLLECTION_UNDEFINED_RATE;
    } else {
	  $shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_COLLECTION_HANDLING_' . $dest_zone);
    }
  }
  $this->quotes = array('id' => $this->code,
					    'module' => MODULE_SHIPPING_COLLECTION_TEXT_TITLE,
					    'methods' => array(array('id' => $this->code,
												 'title' => $shipping_method,
												 'cost' => $shipping_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);
  if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_COLLECTION_INVALID_ZONE;
  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_COLLECTION_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 Collection', 'MODULE_SHIPPING_COLLECTION_STATUS', 'True', 'Do you want to offer this shipping option?', '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, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_COLLECTION_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())");

  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_COLLECTION_SORT_ORDER', '10', 'Sort order of display (1 shown first 99 etc shown last to customer)', '6', '0', now())");

  for ($i = 1; $i <= $this->num_zones; $i++) {
    $default_countries = '';
    if ($i == 1) {
	  $default_countries = 'GB';
    }
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('ISO Country Code', 'MODULE_SHIPPING_COLLECTION_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Enter the two digit ISO code for which this shipping method applies too. (Default: GB)', '6', '0', now())");

  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Collection In Person', 'MODULE_SHIPPING_COLLECTION_COST_" . $i ."', '.1:1.68,.25:1.95,.5:2.38,.75:2.88,1:3.38,1.25:5.42,1.5:6.27,1.75:7.12,2:7.97,2.25:8.82,2.5:9.67,2.75:10.52,3:11.37', 'Enter values upto 5,2 decimal places. (12345.67) Example: .1:1,.25:1.27 - Weights less than or equal to 0.1Kg would cost £1.00, Weights less than or equal to 0.25g but more than 0.1Kg will cost £1.27. Do not enter KG or £ symbols.', '6', '0', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Packaging / Handling Fee', 'MODULE_SHIPPING_COLLECTION_HANDLING_" . $i."', '0', 'If you want to add extra costs to customers for jiffy bags etc, the cost can be entered below (eg enter 1.50 for a value of £1.50)', '6', '0', now())");
  }
   }
   function remove() {
  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
   }
   function keys() {
  $keys = array('MODULE_SHIPPING_COLLECTION_STATUS', 'MODULE_SHIPPING_COLLECTION_TAX_CLASS', 'MODULE_SHIPPING_COLLECTION_SORT_ORDER');
  for ($i=1; $i<=$this->num_zones; $i++) {
    $keys[] = 'MODULE_SHIPPING_COLLECTION_COUNTRIES_' . $i;
    $keys[] = 'MODULE_SHIPPING_COLLECTION_COST_' . $i;
    $keys[] = 'MODULE_SHIPPING_COLLECTION_HANDLING_' . $i;
  }
  return $keys;
   }
 }
?>

Posted

I read the notes and just had to add the word preg in before the word split and it works perfect now

Was all you did was change the function name from split to preg_split? The first parameter (pattern) has different syntax. preg_split requires deilimiters around the pattern, such as / /.

split("[,\s]+", $str)
preg_split("/[,\s]+/", $str)

Archived

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

×
×
  • Create New...