Jump to content
Sign in to follow this  
ansipants

Individual Product Shipping Prices per Zones

Recommended Posts

can't figure out what's causing it. here is the error:

 

Warning: Invalid argument supplied for foreach() in /home/Websites/auctionlot/includes/functions/indvshipzones.php on line 58

 

Here is the code around that line:

 

}

 

function Display($product_id) {

$return = "<table class='main'><tr>";

$nZones = count(GetAllZones());

$i = 1;

foreach(GetAllZones() as $key=>$value) {

$finLigne = "";

if ($i==$nZones) { // Cherche la fin de tableau

$modulo = $i%3; // Nombre de cellules vides restantes

for ($x=0; $x<=$modulo; $x++) {

$finLigne .= "<td></td><td></td>";

}

Share this post


Link to post
Share on other sites
i have the same exact problem. can someone please help?

 

im guessing that the get all zones function query is coming up null......in the same file but the first function up top.....get rid of the where and AND statements and just pull all the stuff from the zones table and it seems to work.....

Share this post


Link to post
Share on other sites

I'm struggling with this contribution too.

 

I'm getting the same error as above but I don't understand why - All my tax zones are set up correctly.

 

Anybody had any sucess with this contribution, I need it to work because it's exactly what I need on my client's store.

Share this post


Link to post
Share on other sites

Anyone can help us??

 

The code

 

function GetAllZones() {

$zones_query = tep_db_query("SELECT z.zone_code, z.zone_name

FROM zones as z,countries as c, configuration as co, geo_zones as g

WHERE co.configuration_value = g.geo_zone_id

AND co.configuration_key = 'MODULE_SHIPPING_INDVSHIP_ZONE'

AND g.geo_zone_name = c.countries_name

AND c.countries_id=z.zone_country_id");

 

while ($row = tep_db_fetch_array($zones_query)) {

$array[$row['zone_code']] = $row['zone_name'];

}

return $array;

}

Edited by davchi2005

Share this post


Link to post
Share on other sites

It would be really nice to get this working.

 

I have a customer that sells large items, and they have a fixed shipping cost to different parts of the country, per item.

 

If anyone can help with this then that would be great (and paid for)

Share this post


Link to post
Share on other sites

I am getting the following error:

 

Port par zone: -

Warning: Invalid argument supplied for foreach() in /home/shop/public_html/includes/functions/indvshipzones.php on line 58

 

Not to sure why. Fresh install of OSC

Share this post


Link to post
Share on other sites

I am also getting the error noted below, along with the error listed above. Any help for either would be greatly appreciated. Thanks.

 

I am getting the following error:

 

Port par zone: -

Warning: Invalid argument supplied for foreach() in /home/shop/public_html/includes/functions/indvshipzones.php on line 58

 

Not to sure why. Fresh install of OSC

Share this post


Link to post
Share on other sites

I have solved the problem and got this module working. Here's what I did:

 

In the indvship.php module file itself, change the $shiptotal variable definition in the quote() function to:

 

   $shiptotal = $cart->get_shiptotal();

 

In the indvshipfunctions.php file in the /includes/functions directory, change the GetAllZones() function to the following:

 

	function GetAllZones() {
	/* $zones_query = tep_db_query("SELECT z.zone_code, z.zone_name 
	FROM zones as z,countries as c, configuration as co, geo_zones as g
	WHERE co.configuration_value = g.geo_zone_id
	AND co.configuration_key = 'MODULE_SHIPPING_INDVSHIP_ZONE'
	AND g.geo_zone_name = c.countries_name
	AND c.countries_id=z.zone_country_id"); */

	$zones_query = tep_db_query("SELECT z.zone_code, z.zone_name
		FROM zones as z");

	while ($row = tep_db_fetch_array($zones_query)) {
		$array[$row['zone_code']] = $row['zone_name'];
	}
	/* echo "<pre>" . print_r($array) . "</pre>"; */
	return $array;
}

 

In the same function, change SetPrices() to the following:

 

	function SetPrices($product_id, $zone_code, $price=0) {
	$zones_query = tep_db_query("SELECT zone_code FROM indvshipzones WHERE product_id = ".$product_id." AND zone_code = \"".$zone_code."\"");
	if ($row = tep_db_fetch_array($zones_query)) {
		tep_db_query("UPDATE indvshipzones SET product_id=$product_id, zone_code='$zone_code', price=$price WHERE product_id = ".$product_id." AND zone_code = '".$zone_code."'");
	} else {
		tep_db_query("INSERT INTO indvshipzones (product_id, zone_code, price) VALUES ($product_id, '$zone_code', $price)");
	}
}

 

In categories.php, change the GetAllZones() function call to the following:

 

// START INDVSHIPZONES
		foreach(GetAllZones() as $key=>$value) {
		/* print 'key is' . $key . '<br />';
		print 'value is' . $value . '<br />';
		print 'post value is ' . $HTTP_POST_VARS[$value] . '<br />';
		print 'post value is ' . $HTTP_POST_VARS[$key] . '<br />';
		print '<pre>' . print_r($HTTP_POST_VARS) . '</pre>'; */
			if(isset($HTTP_POST_VARS[$key])) {
				SetPrices((int)$products_id, $key, $HTTP_POST_VARS[$key]);
			}
		}
// END INDVSHIPZONES
         }

 

I think these are the only changes required to get it working. I also had a problem with the shipping method not displaying in the checkout, but I fixed that by commenting out the strange exception for indvship (whose purpose I could not discover) in the shipping.php class file.

 

Hope this helps!

Share this post


Link to post
Share on other sites

Thanks jstar,

I did your changes and that got me most of the way there. I got one more error during checkout and found that in \includes\classes\shipping.php at about line 20, I needed to change

	  global $language, $PHP_SELF;

to

	  global $language, $PHP_SELF, $cart;

 

Hope it helps the next person. Seems to be working fine in RC1 now.

Share this post


Link to post
Share on other sites

Anyone knows how to make this module to take the zones from the edited taxes zones?

I think the tables name im refering is zones_to_geo_zones. I have been attempting to modify the functions file indvshipzones.php for hours, but im a roockie on mysql querys, i need some help, i am desperating.

:(

 

Thanks!!

 

The original file does this query:

$zones_query = tep_db_query("SELECT z.zone_code, z.zone_name FROM zones as z");

Edited by TROQUELADO

Share this post


Link to post
Share on other sites

I used the original query:

$zones_query = tep_db_query("SELECT z.zone_code, z.zone_name FROM zones z, countries c, configuration co, geo_zones g WHERE co.configuration_key = 'MODULE_SHIPPING_INDVSHIP_ZONE' AND co.configuration_value = g.geo_zone_id AND g.geo_zone_name = c.countries_name AND c.countries_id = z.zone_country_id");

 

In the tax zones I used the country (USA) and added all of states I wanted in "details". I created a new country USA instead of United Sates and added the states I wanted to use in zones first. This gave me only the states I want to use and not everything in zones.

 

Hope this helps

 

Anyone knows how to make this module to take the zones from the edited taxes zones?

I think the tables name im refering is zones_to_geo_zones. I have been attempting to modify the functions file indvshipzones.php for hours, but im a roockie on mysql querys, i need some help, i am desperating.

:(

 

Thanks!!

 

The original file does this query:

$zones_query = tep_db_query("SELECT z.zone_code, z.zone_name FROM zones as z");

Share this post


Link to post
Share on other sites

Thanks to jstar. I have gotten rid of all the errors.

 

However, I still don't see how you can input the shipping price per zone for each product in the Admin panel.

 

Can anyone shed some light on this?

 

Any help will be greatly appreciated. I am eager to get my store running!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×