Okay ... let's first break down what you are trying to do ...
It sounds like you want a Flat Rate flat shipping module to run for the rate of 6.95 ... unless there is 1 or more Products from the aerosols category ... then the Flat Rate flat shipping module should be, for the whole order, set to 15.00 ...
Now the trick is to test the shopping cart for 1 or more Products from the aerosols category ...
Let's assume the aerosols category is categories_id 27 ... if that is the case, when you edit a Product from there, it should list the Master Category ...
Product Master Category:
this will either tell you the ID and Name of the Category or there will be a dropdown list, if this is a Linked Product ...
The "Master Category" is the "Main Category" of a Product, as in the Category that "owns" the Product and is used for other things like Sales, setting the products_price_sorter, etc. etc. where a Master Category has to be known ...
To control the Flat Rate flat shipping module for the amount to charge, we need to test if 1 or more Products are in the aerosols category, which we are using as categories_id 27 ... which would be set in the products table for the master_categories_id 27 ...
To use this to change the Cost of the Flat Rate flat shipping module, you need to test and adjust the rate based on the results ...
Editing the file:
/includes/modules/shipping/flat.php
There is a section of code that generates the quote or the cost:
Code:
// class methods
function quote($method = '') {
global $order;
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
'cost' => MODULE_SHIPPING_FLAT_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);
return $this->quotes;
}
This needs to be changed ...
Code:
// class methods
function quote($method = '') {
global $order;
// check for number of aerosols in cart and change rate if 1 or more are in the cart
global $cart;
$cnt_aerosols = $_SESSION['cart']->in_cart_check('master_categories_id','27');
if ($cnt_aerosols > 0) {
$flat_aerosols = 15.00;
} else {
$flat_aerosols = 0.00;
}
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
'cost' => ($flat_aerosols > 0 ? $flat_aerosols : MODULE_SHIPPING_FLAT_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);
return $this->quotes;
}
Now when products from categories_id 27, based on master_categories_id 27 in the products table are in the cart the rate will be 15.00 rather than what is set in the Flat Rate flat shipping module ...
Easy Smeazy, eh?
Bookmarks