Let's say you wanted to customize Flat Rate shipping to charge $3.50 when products_id 12 is in the cart, regardless of quantity ...
Edit the module and change the function quote to read:
Code:
// class methods
function quote($method = '') {
global $order;
global $cart;
$chk_how_many12 = $_SESSION['cart']->in_cart_check('products_id', '12');
if ($chk_how_many12 > 0) {
// charge 3.50 if products_id 12 is in the cart
$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' => 3.50)));
} else {
// charge regular flat rate if products_id 12 is NOT in the cart
$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;
}