This will count how many products are in the cart from categories_id 1 when the master_categories_id of the Product is set to 1:
Code:
if (!IS_ADMIN_FLAG) {
global cart;
$chk_cat_1 = $_SESSION['cart']->in_cart_check('master_categories_id','1');
}
Then, using the value $chk_cat_1 you can multiply that by whatever price you want to charge ...
Then, find the cost setting in the shipping module and add that to it ...
Example: in the USPS shipping module you would see the code:
Code:
$methods[] = array('id' => $type,
'title' => $title,
'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );
This can be changed to:
Code:
$methods[] = array('id' => $type,
'title' => $title,
'cost' => (($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) + ($chk_cat_1 * 18.95)) );
This would then add the $18.95 per Product per quantity to the USPS shipping quote rate based on the idea that all Products in Category 1 have 0 weight to them ...
NOTE: the USPS shipping module will get a quote based on the lowest possible rate when there is 0 weight in the cart ...
You could disable the USPS shipping module with similar code, based on the Category 1 being the only products in the cart with by changing the code:
Code:
// disable only when entire cart is free shipping
if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
}
to read:
Code:
// disable only when entire cart is free shipping
if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
}
if (!IS_ADMIN_FLAG) {
global cart;
$chk_cat_1 = $_SESSION['cart']->in_cart_check('master_categories_id','1');
if ($chk_cat_1 == $_SESSION['cart']->count_contents()) {
$this->enabled = false;
}
}
Adapting this code can then control which shipping modules show or do not show based on the content of the cart ...