I think it was mentioned earlier that you get into trouble trying to create multiple rules for product categories/types but restricting by product model is more maleable. I have a few flat rates for items that ship from different warehouses. the conceptually easiest thing to do is clone the original "flat" rate and replace all instances of "flat" with a new name, then create a restriction. also remember to clone the languages file and rename it to match the shipping module. but the restrictions by product model as described above definitely work. and you *can *get pretty complex with them. If you only have 3 different product types/models (A, B, C), then it's not too tough. you end up with 7 possible cart combinations that require 7 different scripts: FlatA, FlatB, FlatC, FlatABC, FlatAB, FlatAC, FlatBC. Just "find and replace" with notepad++ a few times to create the additional scripts and create enable/disable rules. it isn't pretty but it works.
Here's a sample of mine where if NAV is the only product type in the cart, the flat rate is triggered. notice that all other product models are explicitly disabled:
class flat {
var $code, $title, $description, $icon, $enabled;
// class constructor
function flat() {
global $order, $db;
$this->code = 'flat';
$this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE;
$this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION;
$this->sort_order = MODULE_SHIPPING_FLAT_SORT_ORDER;
$this->icon = '';
$this->tax_class = MODULE_SHIPPING_FLAT_TAX_CLASS;
$this->tax_basis = MODULE_SHIPPING_FLAT_TAX_BASIS;
// disable only when entire cart is free shipping
if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
}
// enable for one product_id NAV
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','NAV') > 0)) {
$this->enabled = true;
}
// disable for one product_id SD
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','SD') > 0)) {
$this->enabled = false;
}
// disable for one product_id TM
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','TM') > 0)) {
$this->enabled = false;
}
// disable for one product_id SRW
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','SRW') > 0)) {
$this->enabled = false;
}
// disable for one product_id MP
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','MP') > 0)) {
$this->enabled = false;
}
this one is a little more complex. it is triggered when there are two kinds of product models in the cart (NAV and MP):
class flat2 {
var $code, $title, $description, $icon, $enabled;
// class constructor
function flat2() {
global $order, $db;
$this->code = 'flat2';
$this->title = MODULE_SHIPPING_FLAT2_TEXT_TITLE;
$this->description = MODULE_SHIPPING_FLAT2_TEXT_DESCRIPTION;
$this->sort_order = MODULE_SHIPPING_FLAT2_SORT_ORDER;
$this->icon = '';
$this->tax_class = MODULE_SHIPPING_FLAT2_TAX_CLASS;
$this->tax_basis = MODULE_SHIPPING_FLAT2_TAX_BASIS;
// disable only when entire cart is free shipping
if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_FLAT2_STATUS == 'True') ? true : false);
}
// enable for two product_id NAV + MP
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','MP') > 0)&&(IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','NAV') > 0)) {
$this->enabled = true;
}
// disable for one product_id SD
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','SD') > 0)) {
$this->enabled = false;
}
// disable for one product_id TM
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','TM') > 0)) {
$this->enabled = false;
}
// disable for one product_id SRW
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','SRW') > 0)) {
$this->enabled = false;
}
it's the same information that's in the thread already. so if it's not working for you, what kind of errors are you getting? zen cart will tell you if you didn't rename all of the files properly because it will stop loading the shipping modules and throw up an error when it reaches the offending script.
if the scripts all pass the initial zen cart checks, then make sure you have them "installed" but "disabled" (yellow circle).
my examples are are culled from the flat rates, but they apply to any module you want to use. I have similar restrictions on USPS as well. exact same code/values. it's a lot easier just to disallow a shipping option for one or two kinds of models than to account for all possible combinations.
:bigups: