Add to each of the Zone Rates:
0.00:0.00,
so that it can handle when only the 319 category products are in the cart ...
Then, change the function quote in th:
/includes/modules/shipping/zones.php
to read:
Code:
// class methods
function quote($method = '') {
global $order, $shipping_weight, $shipping_num_boxes, $total_count;
$dest_country = $order->delivery['country']['iso_code_2'];
$dest_zone = 0;
$error = false;
$order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
// bof: separate flat charge for master_categories_id 319
global $cart;
$products = $_SESSION['cart']->get_products();
$chk_cost = 0.00;
$chk_count = 0;
$extra_charge = 0.00;
// calculate cost of master_categories_id 319
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
// calculate price and quantity master_categories_id 319
//echo 'Product id: ' . $products[$i]['id'] . ' master: ' . $products[$i]['category'] . '<br>';
if ($products[$i]['category'] == 319) {
$chk_cost += $products[$i]['final_price'];
$chk_count += $products[$i]['quantity'];
}
}
// set extra_charge_amount for UK - GB
if ($chk_count > 0) {
$extra_charge_amount = 1.50;
}
for ($i=1; $i<=$this->num_zones; $i++) {
$countries_table = constant('MODULE_SHIPPING_ZONES_COUNTRIES_' . $i);
$countries_table = strtoupper(str_replace(' ', '', $countries_table));
$country_zones = preg_split("/[,]/", $countries_table);
if (in_array($dest_country, $country_zones)) {
$dest_zone = $i;
break;
}
if (in_array('00', $country_zones)) {
$dest_zone = $i;
// change extra_charge_amount for rest of the world
if ($chk_count > 0) {
$extra_charge_amount = 2.00;
}
break;
}
}
// reduce order total by master_categories_id 319
$order_total_amount -= $chk_cost;
// if master_categories_id 319 are in the cart build extra charge
if ($chk_count > 0) {
$extra_charge = $extra_charge_amount;
}
// if only master_categories_id 319 set total to 0.00
if ($chk_count == $total_count) {
// $order_total_amount = 0.00;
}
//echo ' Order Total: ' . $order_total_amount . ' reduced order by: ' . $chk_cost . ' extra charge: ' . $extra_charge . '<br>';
// eof: separate flat charge for master_categories_id 319
if ($dest_zone == 0) {
$error = true;
} else {
$shipping = -1;
$zones_cost = constant('MODULE_SHIPPING_ZONES_COST_' . $dest_zone);
$zones_table = preg_split("/[:,]/" , $zones_cost);
$size = sizeof($zones_table);
$done = false;
for ($i=0; $i<$size; $i+=2) {
switch (MODULE_SHIPPING_ZONES_METHOD) {
case (MODULE_SHIPPING_ZONES_METHOD == 'Weight'):
if (round($shipping_weight,9) <= $zones_table[$i]) {
$shipping = $zones_table[$i+1];
switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
case (0):
$show_box_weight = '';
break;
case (1):
$show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
break;
case (2):
$show_box_weight = ' (' . number_format($shipping_weight * $shipping_num_boxes,2) . MODULE_SHIPPING_ZONES_TEXT_UNITS . ')';
break;
default:
$show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . MODULE_SHIPPING_ZONES_TEXT_UNITS . ')';
break;
}
// $shipping_method = MODULE_SHIPPING_ZONES_TEXT_WAY . ' ' . $dest_country . (SHIPPING_BOX_WEIGHT_DISPLAY >= 2 ? ' : ' . $shipping_weight . ' ' . MODULE_SHIPPING_ZONES_TEXT_UNITS : '');
$shipping_method = MODULE_SHIPPING_ZONES_TEXT_WAY . ' ' . $dest_country . $show_box_weight;
$done = true;
if (strstr($zones_table[$i+1], '%')) {
$shipping = ($zones_table[$i+1]/100) * $order_total_amount;
} else {
$shipping = $zones_table[$i+1];
}
break;
}
break;
case (MODULE_SHIPPING_ZONES_METHOD == 'Price'):
// shipping adjustment
// bof: separate flat charge for master_categories_id 319
// adjust for Price for master_categories_id 319 by $chk_cost
if ((($_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices()) - $chk_cost) <= $zones_table[$i]) {
// eof: separate flat charge for master_categories_id 319
$shipping = $zones_table[$i+1];
$shipping_method = MODULE_SHIPPING_ZONES_TEXT_WAY . ' ' . $dest_country;
if (strstr($zones_table[$i+1], '%')) {
$shipping = ($zones_table[$i+1]/100) * $order_total_amount;
} else {
$shipping = $zones_table[$i+1];
}
$done = true;
break;
}
break;
case (MODULE_SHIPPING_ZONES_METHOD == 'Item'):
// shipping adjustment
if (($total_count - $_SESSION['cart']->free_shipping_items()) <= $zones_table[$i]) {
$shipping = $zones_table[$i+1];
$shipping_method = MODULE_SHIPPING_ZONES_TEXT_WAY . ' ' . $dest_country;
$done = true;
if (strstr($zones_table[$i+1], '%')) {
$shipping = ($zones_table[$i+1]/100) * $order_total_amount;
} else {
$shipping = $zones_table[$i+1];
}
break;
}
break;
}
if ($done == true) {
break;
}
}
if ($shipping == -1) {
$shipping_cost = 0;
$shipping_method = MODULE_SHIPPING_ZONES_UNDEFINED_RATE;
} else {
switch (MODULE_SHIPPING_ZONES_METHOD) {
case (MODULE_SHIPPING_ZONES_METHOD == 'Weight'):
// charge per box when done by Weight
// Handling fee per box or order
if (constant('MODULE_SHIPPING_ZONES_HANDLING_METHOD_' . $dest_zone) == 'Box') {
$shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_ZONES_HANDLING_' . $dest_zone) * $shipping_num_boxes;
} else {
$shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_ZONES_HANDLING_' . $dest_zone);
}
break;
case (MODULE_SHIPPING_ZONES_METHOD == 'Price'):
// don't charge per box when done by Price
$shipping_cost = ($shipping) + constant('MODULE_SHIPPING_ZONES_HANDLING_' . $dest_zone);
break;
case (MODULE_SHIPPING_ZONES_METHOD == 'Item'):
// don't charge per box when done by Item
$shipping_cost = ($shipping) + constant('MODULE_SHIPPING_ZONES_HANDLING_' . $dest_zone);
break;
}
}
}
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_ZONES_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => $shipping_method,
'cost' => $extra_charge + $shipping_cost)));
if ($this->tax_class > 0) {
$this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
}
if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
if (strstr(MODULE_SHIPPING_ZONES_SKIPPED, $dest_country)) {
// don't show anything for this country
$this->quotes = array();
} else {
if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_ZONES_INVALID_ZONE;
}
return $this->quotes;
}
What this will do is handle the regular products and your category 319 products ...
Bookmarks