You could customize the code for:
/includes/classes/shipping.php
by adding the code in RED:
Code:
function calculate_boxes_weight_and_tare() {
global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes;
$this->abort_legacy_calculations = FALSE;
$this->notify('NOTIFY_SHIPPING_MODULE_PRE_CALCULATE_BOXES_AND_TARE');
if ($this->abort_legacy_calculations) return;
// bof: reduce weight if products_id 10 is in cart for products_id 12, 13 and 15
$reduce_weight = 0;
if ($_SESSION['cart']->in_cart(10)) {
$reduce_weight += $_SESSION['cart']->in_cart_product_total_weight(12);
$reduce_weight += $_SESSION['cart']->in_cart_product_total_weight(13);
$reduce_weight += $_SESSION['cart']->in_cart_product_total_weight(15);
$total_weight = $total_weight - $reduce_weight;
}
// eof: reduce weight if products_id 10 is in cart for products_id 12, 13 and 15
if (is_array($this->modules)) {
and customize the file:
/includes/classes/shopping_cart.php
by adding the code in RED:
Code:
return $new_qty;
}
// bof: reduce weight if products_id 10 is in cart for products_id 12, 13 and 15
/**
* calculate products_id weight in cart regardless of attributes
* USAGE: $product_total_weight = $this->in_cart_product_total_weight(12);
* USAGE: $chk_product_cart_total_weight = $_SESSION['cart']->in_cart_product_total_weight(12);
*
* @param mixed $product_id
* @return float
*/
function in_cart_product_total_weight($product_id) {
$products = $this->get_products();
$in_cart_product_weight = 0;
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
if ((int)$product_id == (int)$products[$i]['id']) {
$in_cart_product_weight += $products[$i]['weight'] * $products[$i]['quantity'];
}
} // end FOR loop
return $in_cart_product_weight;
}
// eof: reduce weight if products_id 10 is in cart for products_id 12, 13 and 15
}
NOTE: the code added to the shopping_cart.php class will not need to be added in a future release of Zen Cart ...
Bookmarks