Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

World Zones 2.0 - help needed with quantity & zone calculation


Recommended Posts

Posted

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

Posted

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

Posted
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:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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