Jump to content
Sign in to follow this  
jpmad4it

World Zones 2.0 - help needed with quantity & zone calculation

Recommended Posts

Hi there

 

I am using this mod:

 

http://addons.oscommerce.com/info/2367

 

It is the latest version World Zones 2.0.

 

I have been trying to experiment with the code in includes/modules/shipping/worldzones.php

 

I wish to say that if the country ISO code equals 'GB' and the cart quantity is greater than or equal to 2, then shipping is free.

 

I have this code so far:

 

// elari - Added to select default country if not in listing
 if ($dest_zone == 0) {
   $dest_zone = $this->num_zones;	// the zone is the lastest zone avalaible
 }
 // elari - Added to select default country if not in listing
 if ($dest_zone == 0) {
   $error = true;	  // this can no more achieve since by default the value is set to the max number of zones
 } else {
   $shipping = -1;
   $zones_cost = constant('MODULE_SHIPPING_WORLDZONES_COST_' . $dest_zone);

//THIS IS MY MODIFICATION

for ($i=0, $n=sizeof($products); $i<$n; $i++) {
	global $cart, $order;
	$products = $cart->get_products();
	$Qty = $products[$i]['quantity'];
}

if ($Qty > 2 && $dest_country == 'GB'){
 	$zones_cost = 0;
}

// Alane - Begin percent mod   
if (MODULE_SHIPPING_WORLDZONES_MODE == 'percent'){
   $shipping = $order_total * $zones_cost;
   $shipping_method = MODULE_SHIPPING_WORLDZONES_TEXT_WAY . ' ' . $order->delivery['country']['title'] . ': ' .MODULE_SHIPPING_WORLDZONES_TEXT_MODE;
   if ($shipping_num_boxes > 1) {
		 $shipping_method .= $shipping_num_boxes . 'x ';
	   }

}  else {
// Alane - End percent mod

 

 

I am trying to get the cart quantity here, and set that number to the variable $Qty. The variable $dest_country is set earlier in the file (I think)

My code is the part under the comment //THIS IS MY MODIFICATION. I placed the other code here so that you could see where in the file I have placed it.

 

Any ideas anyone? As this isn't working for me :-(

 

kind regards

Jp

Share this post


Link to post
Share on other sites

$Qty = $products[$i]['quantity'];

should be

$Qty += $products[$i]['quantity'];


Ask/Skype for Free osCommerce value addon/SEO suggestion tips for your site.

 

Check My About US For who am I and what My company does.

Share this post


Link to post
Share on other sites
Make sure that $dest_country is actually doing anything....

 

Off the top of my head, this looks more useful;

 

if (($cart->count_contents() > 2) && $order->delivery['country']['title'] == 'GB'){
$zones_cost = 0;
}

 

You can get rid of this, I think;

 

for ($i=0, $n=sizeof($products); $i<$n; $i++) {
	global $cart, $order;
	$products = $cart->get_products();
	$Qty = $products[$i]['quantity'];
}

 

This did the trick:

 

if (($cart->count_contents() >= 2) && $dest_country == 'GB'){
$zones_cost = 0;
}

 

As $dest_country is set to $order->delivery['country']['iso_code_2']; earlier in the code!

 

Thanks very much :lol:

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  

×