Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[contribution] individual product shipping prices


Recommended Posts

I have this problem. How can I show only 0.00 format.

 

I spent hours to fix this... but could not find solution.

 

 

I got it.

 

What I did in product_info.tpl.php

 

<?php echo sprintf("%01.2f", $product_info['products_ship_price']); ?>

Link to comment
Share on other sites

  • 3 weeks later...

I show this error when trying to access any of the store pages...any ideas?

 

1146 - Table 'xxxxx_osc1.TABLE_PAGES' doesn't exist

 

select p.pages_id, p.sort_order, p.status, s.pages_title, s.pages_html_text, s.intorext, s.externallink, s.link_target from TABLE_PAGES p LEFT JOIN TABLE_PAGES_DESCRIPTION s on p.pages_id = s.pages_id where p.status = 1 and p.page_type != 1 and s.language_id = '1' order by p.sort_order, s.pages_title

Link to comment
Share on other sites

For now until this gets sorted, how can I reverse these database entries?

 

DROP TABLE IF EXISTS `products_shipping`;

CREATE TABLE `products_shipping` (

`products_id` int(11) NOT NULL default '0',

`products_ship_methods_id` int(11) default NULL,

`products_ship_zip` varchar(32) default NULL,

`products_ship_price` varchar(10) default NULL,

`products_ship_price_two` varchar(10) default NULL

) TYPE=MyISAM;

 

INSERT INTO configuration VALUES ('', 'Indiv Ship Home Country', 'INDIVIDUAL_SHIP_HOME_COUNTRY', '223', 'Individual ship home country ID (other countries will have extra freight)', 7, NULL, '0000-00-00 00:00:00', '0000-00-00 00:00:00', NULL, NULL);

INSERT INTO configuration VALUES ('', 'Indiv Ship Outside Home Increase', 'INDIVIDUAL_SHIP_INCREASE', '3', 'Individual ship x increase for shipping outside home country. For example: If you set your item ship price to $50 and this value to 3 and ship outside your home country they will pay $150, and if this value was 2, they would pay $100.', 7, NULL, '0000-00-00 00:00:00', '0000-00-00 00:00:00', NULL, NULL);

 

A backup from the store admin doesn't seem to be doing the trick.

Link to comment
Share on other sites

I'm having a problem with this module adding itself to my other shipping methods.

 

In other words, if I have a rate set for the Indiividual Shipping, it's added to the total for other options chosen...ie USPS Choice. So instead of someone getting the calculated USPS total, they get the calculated USPS total PLUS the flat rate specified by this (individual shipping) contribution. It doesn't seem to matter what zone I have set for Individual Shipping.

 

If I disable the module without uninstalling it, I still get the amount added to the other methods. If I set the individual shipping value to zero, I then get a normal rate for my other options. I have to completely uninstall AND set the values to zero to get a normal rate for my other methods.

 

Very odd, very bad, & unusable.

Edited by cdi-buy.com
Link to comment
Share on other sites

  • 2 months later...
I have a slight problem with this shipping module. No matter what I set my shipping price to, every time you go to check out it will display a shipping price of $0.00 I am hoping someone else out there has had this problem and knows a quick fix. Thanks for any help!

 

Check to make sure you have included the following

 

 

In catalog\includes\classes\shopping_cart.php

 

Find

 

          $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
         if (tep_db_num_rows($specials_query)) {
           $specials = tep_db_fetch_array($specials_query);
           $products_price = $specials['specials_new_products_price'];
         }

 

Insert AFTER it

 

		  // start indvship
	  $products_shipping_query = tep_db_query("select products_ship_price, products_ship_price_two, products_ship_zip, products_ship_methods_id from " . TABLE_PRODUCTS_SHIPPING . " where products_id = '" . $products['products_id'] . "'");
	  $products_shipping = tep_db_fetch_array($products_shipping_query);
	  // end indvship

 

Find

 

         $products_array[] = array('id' => $products_id,
                                   'name' => $products['products_name'],
                                   'model' => $products['products_model'],
                                   'image' => $products['products_image'],
                                   'price' => $products_price,
                                   'quantity' => $this->contents[$products_id]['qty'],
                                   'weight' => $products['products_weight'],
                                   'final_price' => ($products_price + $this->attributes_price($products_id)),
                                   'tax_class_id' => $products['products_tax_class_id'],

 

Insert AFTER it

 

	  // start indvship
	'products_ship_price' => $products_shipping['products_ship_price'],
	'products_ship_price_two' => $products_shipping['products_ship_price_two'],
	'products_ship_zip' => $products_shipping['products_ship_zip'],
// end  indvship

 

In catalog\includes\classes\order.php

 

Find

      $this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID,
                         'currency' => $currency,
                         'currency_value' => $currencies->currencies[$currency]['value'],
                         'payment_method' => $payment,

 

Insert BEFORE it

 

	  //start indvship
     if($shipping['id']==indvship_indvship){
       $shipping_cost = $shipping['cost'];
       $shipping_title = $shipping['title'];
     } else {
       $shipping_cost = $shipping['cost'] + $shipping['invcost'];
       if ($shipping['invcost'] > 0) {
         $shipping_title = $shipping['title']. ' Plus Flat Rate Shipping';
       } else {
         $shipping_title = $shipping['title'];
       }
     }
     // end indvship 

 

Find

 

                          'subtotal' => 0,
                         'tax' => 0,
                         'tax_groups' => array(),

 

Insert BEFORE it

 

			  // start indvship
                         //'shipping_method' => $shipping['title'],
                         //'shipping_cost' => $shipping['cost'],
                         'shipping_method' => $shipping_title,
                         'shipping_cost' => $shipping_cost, 
		  //end indvship 

 

 

 

Hope that helps

Link to comment
Share on other sites

hello

can someone help

 

i installed the contribution exactly as described, and it works as normal.

 

however, i cannot see any other shipping modules in the checkout, even though i have commented out the line which it says in the instructions.

 

I have modified the previous contibution (so it works) and I changed it so that it will show either Individual Shipping rates or any other module you have installed. On my site I offer Individual Shipping for some light weight products or Canada Post Shipping for the rest. If a customer oders only light weight items, I want them to use the Individual Shipping option only, but if the order anything else or a combination of heavy and light items I want them to use Canada Post only. That is how these files are configured.

If you do not want this either/or option, edit: catalog / includes / classes / shipping.php

comment line 51 - if (($class !='freeshipper') && ($class != 'indvship')) { // comment to show all ship options

uncomment line 52 - //if ($class !='freeshipper') { // uncomment to show all ship options

 

I have come to the conclusion that this contribution does not let you use any other shipping module alongside it.

I installed it exactly as it says on the instructions, yet i cannot use any other shipping module.

 

What the Fck is wrong with this shitty module???

 

can someone explain???

 

it is really pissing me off now.

Edited by vampirehunter
Link to comment
Share on other sites

if anybody knows what is wrong with this module, but there is obviously something wrong with it,

as it does not let you use any other shipping module alongside it.

 

now i will have to reinstall the whole damn thing because of this shitty module.

 

if anybody knows how to fix this problem let me know

Link to comment
Share on other sites

well somebody out there must know a logical way of fixing this.

 

as is stands, i have had to use a hack and basically declare this in the indvshp.php file.

 

What I required is this:

 

1.) Individual postage prices for each item

2.) Once postage cost goes over £6.95, it remains at £6.95 regardless of the quantity of items.

3.) If the price of the items exceeds £100, free postage is given, regardless of the quantity of items

 

Since I cannot use any other shipping module alongside the Individual products shipping module, I have had to do this hack in the indvshp.php file.

 

I added in these lines.

 

if ($shiptotal > 6.95) $shiptotal = 6.95;

 

if($cart->total >100) $shiptotal = 0.00;

 

This seems to make the single module do everything.

 

Is this the correct way of doing it, or is it better to have a seperate shipping module for the "free" shipping option?

Link to comment
Share on other sites

  • 4 weeks later...

Ajax Checkout Vs. Individual Shipping Link

 

Hello, thank you for your contribution. I have a slight problem with this contribution with ajax checkout....

 

I just installed individual shipping with the latest bug fixed backage, with ajax checkout, somehow when i enabled individual shipping module under shipping module, it won't show up as a shipping method in ajax checkout, if i select any other shipping module including the multiple individual shipping module by another person that i installed, it showed up, but i removed multiple individual shipping contribution already, becuase it does not work as i expected. so i use just this individual product shipping prices contribution, and it just won't show in the shipping method in ajax checkout.

 

However, the shipping cost that i enter showed up in product info, and i didn't get any error, so i believe that i installed it correctly.

 

Notes: i use beyond and compare to change or add the code, at the checkout_shipping.php i add this code

								// start indvship
							//'cost' => $quote[0]['methods'][0]['cost']);
							'cost' => $quote[0]['methods'][0]['cost'],
							'invcost' => $shipping_modules->get_shiptotal());
							// end indvship
							// end indvship

to ajaxManagerTest.class.php instead of checkout_shipping.php, becuase ajax checkout use ajaxManagerTest.class.php to select the shipping method.

 

Is there anyway i can get this individual shipping to work with AJAX Checkout?

 

Thank you!

Edited by akunamachata
Link to comment
Share on other sites

Btw... i have solved the Access to the admin area issue.

 

Still waiting for help on the problem with "Check Out"...

errors on catalog/checkout_shipping.php

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resourcein /var/hsphere/local/home/bpbponli/bpbponline.com/catalog/includes/classes/shipping.php on line 33Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resourcein /var/hsphere/local/home/bpbponli/bpbponline.com/catalog/includes/classes/shipping.php on line 66Fatal error: Call to undefined function: get_shiptotal() in /var/hsphere/local/home/bpbponli/bpbponline.com/catalog/includes/modules/shipping/indvship.php on line 53

 

 

Hello Shana,

 

i have fixed this bug, and here you go, just copy this code down and use winmerge to compare, if your shipping class.php does not contains anything special then simply just replace it... but do a winmerge to make sure...

 

this fixed the sql error and seems like you missing get_shiptotal() function and also you missed place the code...

 

<?php
/*
 $Id: shipping.php,v 1.23 2003/06/29 11:22:05 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class shipping {
var $modules;

// class constructor
function shipping($module = '') {

  // INDIV_SM START
  // global $language, $PHP_SELF;
  global $language, $PHP_SELF, $cart;
  // New to fix attributes bug
  $cart_products = $cart->get_products();
  if (tep_not_null($cart_products)) {
		  $real_ids = array();
		  foreach($cart_products as $prod){
			  $real_ids[] = tep_get_prid($prod['id']);
		  }
			$sql = "SELECT products_ship_methods_id FROM ".TABLE_PRODUCTS_SHIPPING." WHERE products_id IN (".implode(',',$real_ids).") AND products_ship_methods_id IS NOT NULL AND products_ship_methods_id <> ''";
			$query = mysql_query($sql);
		  // End new bug fix
			$allow_mod_array = array();
			while($rec = mysql_fetch_array($query)){
				if(empty($allow_mod_array)) $startedempty = true;
				$methods_array = array();
				$methods_array = explode(';',$rec['products_ship_methods_id']);
				if(!empty($methods_array)){
					foreach($methods_array as $method){
						$allow_mod_array[] = $method;
					}
				}
				if($startedempty){
					$startedempty = false;
				}else{
					$temp_array = array();
					foreach($allow_mod_array as $val){
						$temp_array[$val]++;
					}
					$allow_mod_array = array();
					foreach($temp_array as $key => $val){
						if($val > 1){
							$allow_mod_array[] = $key;
						}
					}
				}
			}
	}
  // INDIV_SM END 
  if (defined('MODULE_SHIPPING_INSTALLED') && tep_not_null(MODULE_SHIPPING_INSTALLED)) {
	$this->modules = explode(';', MODULE_SHIPPING_INSTALLED);

	$include_modules = array();

	if ( (tep_not_null($module)) && (in_array(substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $this->modules)) ) {
	  $include_modules[] = array('class' => substr($module['id'], 0, strpos($module['id'], '_')), 'file' => substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)));
	} else {
	  reset($this->modules);

	// start indvship
	  //while (list(, $value) = each($this->modules)) {
	  //  $class = substr($value, 0, strrpos($value, '.'));
	  //  $include_modules[] = array('class' => $class, 'file' => $value);
	  //}
	//}
	  if($indvcount==sizeof($products)){
		if ((tep_get_configuration_key_value('MODULE_SHIPPING_INDVSHIP_STATUS')) && ((tep_not_null($shiptotal)) || $shiptotal == 0)) {
			$include_modules[] = array('class'=> 'indvship', 'file' => 'indvship.php');
		}
	  } else { 
		  if(sizeof($products)>$indvcount){
			while (list(, $value) = each($this->modules)) {
				$class = substr($value, 0, strrpos($value, '.'));
				if (($class !='freeshipper') && ($class != 'indvship')) { // comment to show all ship options
				//if ($class !='freeshipper') { // uncomment to show all ship options
					$include_modules[] = array('class' => $class, 'file' => $value);
				}
			}
		}
	  }
	}
	// end indvship

	for ($i=0, $n=sizeof($include_modules); $i<$n; $i++) {
	  include(DIR_WS_LANGUAGES . $language . '/modules/shipping/' . $include_modules[$i]['file']);
	  include(DIR_WS_MODULES . 'shipping/' . $include_modules[$i]['file']);

	  $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class'];
	}
  }
}

function quote($method = '', $module = '') {
  global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes;

  $quotes_array = array();

  if (is_array($this->modules)) {
	$shipping_quoted = '';
	$shipping_num_boxes = 1;
	$shipping_weight = $total_weight;

	if (SHIPPING_BOX_WEIGHT >= $shipping_weight*SHIPPING_BOX_PADDING/100) {
	  $shipping_weight = $shipping_weight+SHIPPING_BOX_WEIGHT;
	} else {
	  $shipping_weight = $shipping_weight + ($shipping_weight*SHIPPING_BOX_PADDING/100);
	}

	if ($shipping_weight > SHIPPING_MAX_WEIGHT) { // Split into many boxes
	  $shipping_num_boxes = ceil($shipping_weight/SHIPPING_MAX_WEIGHT);
	  $shipping_weight = $shipping_weight/$shipping_num_boxes;
	}

	$include_quotes = array();

	reset($this->modules);
	while (list(, $value) = each($this->modules)) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  if (tep_not_null($module)) {
		if ( ($module == $class) && ($GLOBALS[$class]->enabled) ) {
		  $include_quotes[] = $class;
		}
	  } elseif ($GLOBALS[$class]->enabled) {
		$include_quotes[] = $class;
	  }
	}

	$size = sizeof($include_quotes);
	for ($i=0; $i<$size; $i++) {
	  $quotes = $GLOBALS[$include_quotes[$i]]->quote($method);
	  if (is_array($quotes)) $quotes_array[] = $quotes;
	}
  }

  return $quotes_array;
}

//start indvship
function get_shiptotal() {
  global $cart, $order;
  $this->shiptotal = '';
  $products = $cart->get_products();
  for ($i=0, $n=sizeof($products); $i<$n; $i++) {
	if (tep_not_null($products[$i]['products_ship_price'])) {
	  $products_ship_price = $products[$i]['products_ship_price'];
	  $products_ship_price_two = $products[$i]['products_ship_price_two'];
	  $products_ship_zip = $products[$i]['products_ship_zip'];
	  $qty = $products[$i]['quantity'];
	  if(tep_not_null($products_ship_price) ||tep_not_null($products_ship_price_two)){
		$this->shiptotal += ($products_ship_price);
		if ($qty > 1) {
		  if (tep_not_null($products_ship_price_two)) {
			$this->shiptotal += ($products_ship_price_two * ($qty-1));
		  } else {
			$this->shiptotal += ($products_ship_price * ($qty-1));
		  }
		}/////////////NOT HERE <<------------
	  }
	}
  }// CHECK TO SEE IF SHIPPING TO HOME COUNTRY, IF NOT INCREASE SHIPPING COSTS BY AMOUNT SET IN ADMIN/////////////move back here <<------------
  if (($order->delivery['country']['id']) != INDIVIDUAL_SHIP_HOME_COUNTRY) {
	if(INDIVIDUAL_SHIP_INCREASE > '0' || $this->shiptotal > '0') {
	  $this->shiptotal *= INDIVIDUAL_SHIP_INCREASE;
	} else {
	  $this->shiptotal += INDIVIDUAL_SHIP_INCREASE *  $this->get_indvcount();
	}
	return $this->shiptotal;
	// not sure why this is needed, but it now works correctly for home country - by Ed
  } else {
	   $this->shiptotal *= 1;
	 return $this->shiptotal;
  }
}

function get_indvcount() {
  global $cart;
  $this->indvcount = '';
  $products = $cart->get_products();
  for ($i=0, $n=sizeof($products); $i<$n; $i++) {
	if (tep_not_null($products[$i]['products_ship_price'])) {
	  $products_ship_price = $products[$i]['products_ship_price'];//}
	  $products_ship_price_two = $products[$i]['products_ship_price_two'];
	  if(is_numeric($products_ship_price)){
		$this->indvcount += '1';
	  }
	}
  }
  return $this->indvcount;
}

// end indvship

function cheapest() {
  if (is_array($this->modules)) {
	$rates = array();

	reset($this->modules);
	while (list(, $value) = each($this->modules)) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  if ($GLOBALS[$class]->enabled) {
		$quotes = $GLOBALS[$class]->quotes;
		for ($i=0, $n=sizeof($quotes['methods']); $i<$n; $i++) {
		  if (isset($quotes['methods'][$i]['cost']) && tep_not_null($quotes['methods'][$i]['cost'])) {
			$rates[] = array('id' => $quotes['id'] . '_' . $quotes['methods'][$i]['id'],
							 'title' => $quotes['module'] . ' (' . $quotes['methods'][$i]['title'] . ')',
							 'cost' => $quotes['methods'][$i]['cost']);
		  }
		}
	  }
	}

	$cheapest = false;
	for ($i=0, $n=sizeof($rates); $i<$n; $i++) {
	  if (is_array($cheapest)) {
		if ($rates[$i]['cost'] < $cheapest['cost']) {
		  $cheapest = $rates[$i];
		}
	  } else {
		$cheapest = $rates[$i];
	  }
	}

	return $cheapest;
  }
}
 }
?>

Link to comment
Share on other sites

this code should be the correct one!

 

<?php
/*
 $Id: shipping.php,v 1.23 2003/06/29 11:22:05 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class shipping {
var $modules;

// class constructor
function shipping($module = '') {

  // start indvship
  // global $language, $PHP_SELF;
  global $language, $PHP_SELF, $cart;
  // New to fix attributes bug
  $cart_products = $cart->get_products();
  if (tep_not_null($cart_products)) {
		  $real_ids = array();
		  foreach($cart_products as $prod){
			  $real_ids[] = tep_get_prid($prod['id']);
		  }
			$sql = "SELECT products_ship_methods_id FROM ".TABLE_PRODUCTS_SHIPPING." WHERE products_id IN (".implode(',',$real_ids).") AND products_ship_methods_id IS NOT NULL AND products_ship_methods_id <> ''";
			$query = mysql_query($sql);
		  // End new bug fix
			$allow_mod_array = array();
			while($rec = mysql_fetch_array($query)){
				if(empty($allow_mod_array)) $startedempty = true;
				$methods_array = array();
				$methods_array = explode(';',$rec['products_ship_methods_id']);
				if(!empty($methods_array)){
					foreach($methods_array as $method){
						$allow_mod_array[] = $method;
					}
				}
				if($startedempty){
					$startedempty = false;
				}else{
					$temp_array = array();
					foreach($allow_mod_array as $val){
						$temp_array[$val]++;
					}
					$allow_mod_array = array();
					foreach($temp_array as $key => $val){
						if($val > 1){
							$allow_mod_array[] = $key;
						}
					}
				}
			}
	}
  // INDIV_SM END 
  if (defined('MODULE_SHIPPING_INSTALLED') && tep_not_null(MODULE_SHIPPING_INSTALLED)) {
	$this->modules = explode(';', MODULE_SHIPPING_INSTALLED);
			// INDIV_SM START
			if (tep_not_null($cart_products)) {
				$temp_array = $this->modules;
				$this->modules = array();
				foreach($temp_array as $val){
					if(mysql_num_rows($query)==0 || in_array(str_replace('.php','',$val),$allow_mod_array)) {
						$this->modules[] = $val;
					}
				}
			}
			// INDIV_SM END		
	$include_modules = array();

	if ( (tep_not_null($module)) && (in_array(substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $this->modules)) ) {
	  $include_modules[] = array('class' => substr($module['id'], 0, strpos($module['id'], '_')), 'file' => substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)));
	} else {
	  reset($this->modules);

	// start indvship
	  //while (list(, $value) = each($this->modules)) {
	  //  $class = substr($value, 0, strrpos($value, '.'));
	  //  $include_modules[] = array('class' => $class, 'file' => $value);
	  //}
	//}
	  if($indvcount==sizeof($products)){
		if ((tep_get_configuration_key_value('MODULE_SHIPPING_INDVSHIP_STATUS')) && ((tep_not_null($shiptotal)) || $shiptotal == 0)) {
			$include_modules[] = array('class'=> 'indvship', 'file' => 'indvship.php');
		}
	  } else { 
		  if(sizeof($products)>$indvcount){
			while (list(, $value) = each($this->modules)) {
				$class = substr($value, 0, strrpos($value, '.'));
				if (($class !='freeshipper') && ($class != 'indvship')) { // comment to show all ship options
				//if ($class !='freeshipper') { // uncomment to show all ship options
					$include_modules[] = array('class' => $class, 'file' => $value);
				}
			}
		}
	  }
	}
	// end indvship

	for ($i=0, $n=sizeof($include_modules); $i<$n; $i++) {
	  include(DIR_WS_LANGUAGES . $language . '/modules/shipping/' . $include_modules[$i]['file']);
	  include(DIR_WS_MODULES . 'shipping/' . $include_modules[$i]['file']);

	  $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class'];
	}
  }
}

function quote($method = '', $module = '') {
  global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes;

  $quotes_array = array();

  if (is_array($this->modules)) {
	$shipping_quoted = '';
	$shipping_num_boxes = 1;
	$shipping_weight = $total_weight;

	if (SHIPPING_BOX_WEIGHT >= $shipping_weight*SHIPPING_BOX_PADDING/100) {
	  $shipping_weight = $shipping_weight+SHIPPING_BOX_WEIGHT;
	} else {
	  $shipping_weight = $shipping_weight + ($shipping_weight*SHIPPING_BOX_PADDING/100);
	}

	if ($shipping_weight > SHIPPING_MAX_WEIGHT) { // Split into many boxes
	  $shipping_num_boxes = ceil($shipping_weight/SHIPPING_MAX_WEIGHT);
	  $shipping_weight = $shipping_weight/$shipping_num_boxes;
	}

	$include_quotes = array();

	reset($this->modules);
	while (list(, $value) = each($this->modules)) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  if (tep_not_null($module)) {
		if ( ($module == $class) && ($GLOBALS[$class]->enabled) ) {
		  $include_quotes[] = $class;
		}
	  } elseif ($GLOBALS[$class]->enabled) {
		$include_quotes[] = $class;
	  }
	}

	$size = sizeof($include_quotes);
	for ($i=0; $i<$size; $i++) {
	  $quotes = $GLOBALS[$include_quotes[$i]]->quote($method);
	  if (is_array($quotes)) $quotes_array[] = $quotes;
	}
  }

  return $quotes_array;
}

//start indvship
function get_shiptotal() {
  global $cart, $order;
  $this->shiptotal = '';
  $products = $cart->get_products();
  for ($i=0, $n=sizeof($products); $i<$n; $i++) {
	if (tep_not_null($products[$i]['products_ship_price'])) {
	  $products_ship_price = $products[$i]['products_ship_price'];
	  $products_ship_price_two = $products[$i]['products_ship_price_two'];
	  $products_ship_zip = $products[$i]['products_ship_zip'];
	  $qty = $products[$i]['quantity'];
	  if(tep_not_null($products_ship_price) ||tep_not_null($products_ship_price_two)){
		$this->shiptotal += ($products_ship_price);
		if ($qty > 1) {
		  if (tep_not_null($products_ship_price_two)) {
			$this->shiptotal += ($products_ship_price_two * ($qty-1));
		  } else {
			$this->shiptotal += ($products_ship_price * ($qty-1));
		  }
		}/////////////NOT HERE <<------------
	  }
	}
  }// CHECK TO SEE IF SHIPPING TO HOME COUNTRY, IF NOT INCREASE SHIPPING COSTS BY AMOUNT SET IN ADMIN/////////////move back here <<------------
  if (($order->delivery['country']['id']) != INDIVIDUAL_SHIP_HOME_COUNTRY) {
	if(INDIVIDUAL_SHIP_INCREASE > '0' || $this->shiptotal > '0') {
	  $this->shiptotal *= INDIVIDUAL_SHIP_INCREASE;
	} else {
	  $this->shiptotal += INDIVIDUAL_SHIP_INCREASE *  $this->get_indvcount();
	}
	return $this->shiptotal;
	// not sure why this is needed, but it now works correctly for home country - by Ed
  } else {
	   $this->shiptotal *= 1;
	 return $this->shiptotal;
  }
}

function get_indvcount() {
  global $cart;
  $this->indvcount = '';
  $products = $cart->get_products();
  for ($i=0, $n=sizeof($products); $i<$n; $i++) {
	if (tep_not_null($products[$i]['products_ship_price'])) {
	  $products_ship_price = $products[$i]['products_ship_price'];//}
	  $products_ship_price_two = $products[$i]['products_ship_price_two'];
	  if(is_numeric($products_ship_price)){
		$this->indvcount += '1';
	  }
	}
  }
  return $this->indvcount;
}

// end indvship

function cheapest() {
  if (is_array($this->modules)) {
	$rates = array();

	reset($this->modules);
	while (list(, $value) = each($this->modules)) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  if ($GLOBALS[$class]->enabled) {
		$quotes = $GLOBALS[$class]->quotes;
		for ($i=0, $n=sizeof($quotes['methods']); $i<$n; $i++) {
		  if (isset($quotes['methods'][$i]['cost']) && tep_not_null($quotes['methods'][$i]['cost'])) {
			$rates[] = array('id' => $quotes['id'] . '_' . $quotes['methods'][$i]['id'],
							 'title' => $quotes['module'] . ' (' . $quotes['methods'][$i]['title'] . ')',
							 'cost' => $quotes['methods'][$i]['cost']);
		  }
		}
	  }
	}

	$cheapest = false;
	for ($i=0, $n=sizeof($rates); $i<$n; $i++) {
	  if (is_array($cheapest)) {
		if ($rates[$i]['cost'] < $cheapest['cost']) {
		  $cheapest = $rates[$i];
		}
	  } else {
		$cheapest = $rates[$i];
	  }
	}

	return $cheapest;
  }
}
 }
?>

Link to comment
Share on other sites

I was having the same problem that only individual product is showing at checkout_shipping. So i looked throught the catalog/includes/classes/shipping.php.

 

And i found this block of code

 

		// start indvship
	  //while (list(, $value) = each($this->modules)) {
	  //  $class = substr($value, 0, strrpos($value, '.'));
	  //  $include_modules[] = array('class' => $class, 'file' => $value);
	  //}
	//}

	  if($indvcount==sizeof($products)){
		if ((tep_get_configuration_key_value('MODULE_SHIPPING_INDVSHIP_STATUS')) && ((tep_not_null($shiptotal)) || $shiptotal == 0)) {
			$include_modules[] = array('class'=> 'indvship', 'file' => 'indvship.php');
		}
	  } else { 
		  if(sizeof($products)>$indvcount){
			while (list(, $value) = each($this->modules)) {
				$class = substr($value, 0, strrpos($value, '.'));
				if (($class !='freeshipper') && ($class != 'indvship')) { // comment to show all ship options
				// if ($class !='freeshipper') { // uncomment to show all ship options
					$include_modules[] = array('class' => $class, 'file' => $value);
				}
			}
		}
	  }
	}
	// end indvship

 

 

find where it say:

// if ($class !='freeshipper') { // uncomment to show all ship options

 

i've tried to uncommented it, and comment the line:

if (($class !='freeshipper') && ($class != 'indvship')) { // comment to show all ship options

 

and it won't show...

 

However, if i replace this block of code,

 

 

		// start indvship
	  //while (list(, $value) = each($this->modules)) {
	  //  $class = substr($value, 0, strrpos($value, '.'));
	  //  $include_modules[] = array('class' => $class, 'file' => $value);
	  //}
	//}

	  if($indvcount==sizeof($products)){
		if ((tep_get_configuration_key_value('MODULE_SHIPPING_INDVSHIP_STATUS')) && ((tep_not_null($shiptotal)) || $shiptotal == 0)) {
			$include_modules[] = array('class'=> 'indvship', 'file' => 'indvship.php');
		}
	  } else { 
		  if(sizeof($products)>$indvcount){
			while (list(, $value) = each($this->modules)) {
				$class = substr($value, 0, strrpos($value, '.'));
				if (($class !='freeshipper') && ($class != 'indvship')) { // comment to show all ship options
				// if ($class !='freeshipper') { // uncomment to show all ship options
					$include_modules[] = array('class' => $class, 'file' => $value);
				}
			}
		}
	  }
	}
	// end indvship

 

 

with this

 

 

		  while (list(, $value) = each($this->modules)) {
		$class = substr($value, 0, strrpos($value, '.'));
		$include_modules[] = array('class' => $class, 'file' => $value);
	  }
	}

 

please do comment your existing code, so you don't have to go over the file to replace it incase there's a fix...

 

here's an example of comple modification

 

 

<?php
/*
 $Id: shipping.php,v 1.23 2003/06/29 11:22:05 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class shipping {
var $modules;

// class constructor
function shipping($module = '') {

  // start indvship
  // global $language, $PHP_SELF;
  global $language, $PHP_SELF, $cart;
  // New to fix attributes bug
  $cart_products = $cart->get_products();
  if (tep_not_null($cart_products)) {
		  $real_ids = array();
		  foreach($cart_products as $prod){
			  $real_ids[] = tep_get_prid($prod['id']);
		  }
			$sql = "SELECT products_ship_methods_id FROM ".TABLE_PRODUCTS_SHIPPING." WHERE products_id IN (".implode(',',$real_ids).") AND products_ship_methods_id IS NOT NULL AND products_ship_methods_id <> ''";
			$query = mysql_query($sql);
		  // End new bug fix
			$allow_mod_array = array();
			while($rec = mysql_fetch_array($query)){
				if(empty($allow_mod_array)) $startedempty = true;
				$methods_array = array();
				$methods_array = explode(';',$rec['products_ship_methods_id']);
				if(!empty($methods_array)){
					foreach($methods_array as $method){
						$allow_mod_array[] = $method;
					}
				}
				if($startedempty){
					$startedempty = false;
				}else{
					$temp_array = array();
					foreach($allow_mod_array as $val){
						$temp_array[$val]++;
					}
					$allow_mod_array = array();
					foreach($temp_array as $key => $val){
						if($val > 1){
							$allow_mod_array[] = $key;
						}
					}
				}
			}
	}
  // INDIV_SM END 
  if (defined('MODULE_SHIPPING_INSTALLED') && tep_not_null(MODULE_SHIPPING_INSTALLED)) {
	$this->modules = explode(';', MODULE_SHIPPING_INSTALLED);
			// INDIV_SM START
			if (tep_not_null($cart_products)) {
				$temp_array = $this->modules;
				$this->modules = array();
				foreach($temp_array as $val){
					if(mysql_num_rows($query)==0 || in_array(str_replace('.php','',$val),$allow_mod_array)) {
						$this->modules[] = $val;
					}
				}
			}
			// INDIV_SM END		
	$include_modules = array();

	if ( (tep_not_null($module)) && (in_array(substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $this->modules)) ) {
	  $include_modules[] = array('class' => substr($module['id'], 0, strpos($module['id'], '_')), 'file' => substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)));
	} else {
	  reset($this->modules);
	  //// original block >>>>
	  while (list(, $value) = each($this->modules)) {
		$class = substr($value, 0, strrpos($value, '.'));
		$include_modules[] = array('class' => $class, 'file' => $value);
	  }
	}
	//// end original block <<<<
	/* >>>> below where it doesn't show all option, and doesn't seem nessecarily needed <<<<<<<<<<<
	// start indvship
	  //while (list(, $value) = each($this->modules)) {
	  //  $class = substr($value, 0, strrpos($value, '.'));
	  //  $include_modules[] = array('class' => $class, 'file' => $value);
	  //}
	//}

	  if($indvcount==sizeof($products)){
		if ((tep_get_configuration_key_value('MODULE_SHIPPING_INDVSHIP_STATUS')) && ((tep_not_null($shiptotal)) || $shiptotal == 0)) {
			$include_modules[] = array('class'=> 'indvship', 'file' => 'indvship.php');
		}
	  } else { 
		  if(sizeof($products)>$indvcount){
			while (list(, $value) = each($this->modules)) {
				$class = substr($value, 0, strrpos($value, '.'));
				if (($class !='freeshipper') && ($class != 'indvship')) { // comment to show all ship options
				// if ($class !='freeshipper') { // uncomment to show all ship options
					$include_modules[] = array('class' => $class, 'file' => $value);
				}
			}
		}
	  }
	}
	// end indvship
	*/
	for ($i=0, $n=sizeof($include_modules); $i<$n; $i++) {
	  include(DIR_WS_LANGUAGES . $language . '/modules/shipping/' . $include_modules[$i]['file']);
	  include(DIR_WS_MODULES . 'shipping/' . $include_modules[$i]['file']);

	  $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class'];
	}
  }
}

function quote($method = '', $module = '') {
  global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes;

  $quotes_array = array();

  if (is_array($this->modules)) {
	$shipping_quoted = '';
	$shipping_num_boxes = 1;
	$shipping_weight = $total_weight;

	if (SHIPPING_BOX_WEIGHT >= $shipping_weight*SHIPPING_BOX_PADDING/100) {
	  $shipping_weight = $shipping_weight+SHIPPING_BOX_WEIGHT;
	} else {
	  $shipping_weight = $shipping_weight + ($shipping_weight*SHIPPING_BOX_PADDING/100);
	}

	if ($shipping_weight > SHIPPING_MAX_WEIGHT) { // Split into many boxes
	  $shipping_num_boxes = ceil($shipping_weight/SHIPPING_MAX_WEIGHT);
	  $shipping_weight = $shipping_weight/$shipping_num_boxes;
	}

	$include_quotes = array();

	reset($this->modules);
	while (list(, $value) = each($this->modules)) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  if (tep_not_null($module)) {
		if ( ($module == $class) && ($GLOBALS[$class]->enabled) ) {
		  $include_quotes[] = $class;
		}
	  } elseif ($GLOBALS[$class]->enabled) {
		$include_quotes[] = $class;
	  }
	}

	$size = sizeof($include_quotes);
	for ($i=0; $i<$size; $i++) {
	  $quotes = $GLOBALS[$include_quotes[$i]]->quote($method);
	  if (is_array($quotes)) $quotes_array[] = $quotes;
	}
  }

  return $quotes_array;
}

//start indvship
function get_shiptotal() {
  global $cart, $order;
  $this->shiptotal = '';
  $products = $cart->get_products();
  for ($i=0, $n=sizeof($products); $i<$n; $i++) {
	if (tep_not_null($products[$i]['products_ship_price'])) {
	  $products_ship_price = $products[$i]['products_ship_price'];
	  $products_ship_price_two = $products[$i]['products_ship_price_two'];
	  $products_ship_zip = $products[$i]['products_ship_zip'];
	  $qty = $products[$i]['quantity'];
	  if(tep_not_null($products_ship_price) ||tep_not_null($products_ship_price_two)){
		$this->shiptotal += ($products_ship_price);
		if ($qty > 1) {
		  if (tep_not_null($products_ship_price_two)) {
			$this->shiptotal += ($products_ship_price_two * ($qty-1));
		  } else {
			$this->shiptotal += ($products_ship_price * ($qty-1));
		  }
		}/////////////NOT HERE <<------------
	  }
	}
  }// CHECK TO SEE IF SHIPPING TO HOME COUNTRY, IF NOT INCREASE SHIPPING COSTS BY AMOUNT SET IN ADMIN/////////////move back here <<------------
  if (($order->delivery['country']['id']) != INDIVIDUAL_SHIP_HOME_COUNTRY) {
	if(INDIVIDUAL_SHIP_INCREASE > '0' || $this->shiptotal > '0') {
	  $this->shiptotal *= INDIVIDUAL_SHIP_INCREASE;
	} else {
	  $this->shiptotal += INDIVIDUAL_SHIP_INCREASE *  $this->get_indvcount();
	}
	return $this->shiptotal;
	// not sure why this is needed, but it now works correctly for home country - by Ed
  } else {
	   $this->shiptotal *= 1;
	 return $this->shiptotal;
  }
}

function get_indvcount() {
  global $cart;
  $this->indvcount = '';
  $products = $cart->get_products();
  for ($i=0, $n=sizeof($products); $i<$n; $i++) {
	if (tep_not_null($products[$i]['products_ship_price'])) {
	  $products_ship_price = $products[$i]['products_ship_price'];//}
	  $products_ship_price_two = $products[$i]['products_ship_price_two'];
	  if(is_numeric($products_ship_price)){
		$this->indvcount += '1';
	  }
	}
  }
  return $this->indvcount;
}

// end indvship

function cheapest() {
  if (is_array($this->modules)) {
	$rates = array();

	reset($this->modules);
	while (list(, $value) = each($this->modules)) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  if ($GLOBALS[$class]->enabled) {
		$quotes = $GLOBALS[$class]->quotes;
		for ($i=0, $n=sizeof($quotes['methods']); $i<$n; $i++) {
		  if (isset($quotes['methods'][$i]['cost']) && tep_not_null($quotes['methods'][$i]['cost'])) {
			$rates[] = array('id' => $quotes['id'] . '_' . $quotes['methods'][$i]['id'],
							 'title' => $quotes['module'] . ' (' . $quotes['methods'][$i]['title'] . ')',
							 'cost' => $quotes['methods'][$i]['cost']);
		  }
		}
	  }
	}

	$cheapest = false;
	for ($i=0, $n=sizeof($rates); $i<$n; $i++) {
	  if (is_array($cheapest)) {
		if ($rates[$i]['cost'] < $cheapest['cost']) {
		  $cheapest = $rates[$i];
		}
	  } else {
		$cheapest = $rates[$i];
	  }
	}

	return $cheapest;
  }
}
 }
?>

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

I installed v4.3 and used the fix from 4.4 in ver osc2.2. The admin side seems to be working fine but I get this at the catalog end - Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory.

 

Does any kind soul have any idea why.

 

Thanks in advance

Link to comment
Share on other sites

Sorted it thanks. Found problems were eminating from the application_top.php file. There is a piece of code in there which refers to 'compatability' it needs leaving out when u edit the old file and also the piece that refers to 'Globals'

Link to comment
Share on other sites

  • 2 weeks later...

Hi guys,

 

Could this also work with flat rate if no price present?

 

I sell tickets - I want the tickets to be free shipping, so I will set the price to 0.00 BUT everything else, regardles of order size should be the flat rate fee of £6.00.

 

Could this module do it for me?

 

Cheers,

 

Mike

Link to comment
Share on other sites

Hello vereybody,

 

I also tried to install the individual product shipping V4 module. Everything went okay (I thought) Then the problem came when I tried to order something.

 

When I reached the checkout_shipping.php my whole screen went White with nothing on it. What couldt possibly went wrong ? I followed all the steps in the installation guide.

 

Greetins from holland and thanks for helping me out with this problem

Link to comment
Share on other sites

  • 3 weeks later...

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