There is a nice function in the shopping_cart class to check if something exists in the cart based on what you pass it:
function in_cart_check($check_what, $check_value='1') {
If you were to use this to control the shipping option(s) you want disabled by utilizing IF statements you can check if the categories_id 2 for the master_categories_id exists ...
PHP Code:
$_SESSION['cart']->in_cart_check('master_categories_id','2');
Here is an example in the
/includes/modules/shipping/item.php
In the function quote, change the quote to read:
PHP Code:
if ($_SESSION['cart']->in_cart_check('master_categories_id','2')) {
$yes = 'hello world';
}
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_ITEM_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_ITEM_TEXT_WAY . $yes,
'cost' => (MODULE_SHIPPING_ITEM_COST * $item_total_count) + MODULE_SHIPPING_ITEM_HANDLING)));
What this will do is say Hello World next to the title if the master_categories_id is 2 for even 1 product ...
So if 1 product is a truffle ... you see Hello World ...
Now what you can do is customize USPS based on the same idea ...
Find the function quote ...
change the code:
PHP Code:
$methods[] = array('id' => $type,
'title' => $title,
'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
To include a test for your category for truffles
PHP Code:
if (($this->types[$type] == 'Priority Mail') && $_SESSION['cart']->in_cart_check('master_categories_id','2') > 0) {
$skip_this = true;
} else {
$skip_this = false;
}
if (!$skip_this) {
$methods[] = array('id' => $type,
'title' => $title,
'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
}
Bookmarks