If this is your first visit, check our documentation. To post, register or login.
Forums / Built-in Shipping and Payment Modules / Different shipping methods for different categories

Different shipping methods for different categories

Started by tylerd213 on 13 Mar 2008, 2:16 AM · Views: 107,884

Results 281 to 300 of 554
29 Oct 2010, 4:07 AM
#281
trice avatar

trice

New Zenner

Join Date:
Oct 2010
Posts:
26
Plugin Contributions:
0

Different shipping methods for different categories

Ajeh:

It would take quite a bit of customizing to work in a 50% discount ...

What happens when 3 bagship are in the cart or 4? :unsure:

Ok so I have it working with table rate, one table rate for each model that is chosen, I still have the issue as how to combine the shipping at the checkout so I see one line of shipping not two lines for the customer to pick from, different prices depending on what is in the cart. how do I combine this?

29 Oct 2010, 4:36 AM
#282
trice avatar

trice

New Zenner

Join Date:
Oct 2010
Posts:
26
Plugin Contributions:
0

Re: Different shipping methods for different categories

Trice:

Ok so I talked the person that I am creating this for into making my life simple. I told her I was gonna lock her in the closet if she didn't cut me a break.....:D

Anyway I'm going to work on this later tonight, but will you tell me if this is possible

Going to use the table rate for both bagship and reg (still basising it on what is entered into the model number)

Will I be able to combine those into one table shipping module?

Ok so that was incorrect, I price of shipping is not based on the amount entered into model number. Using the table for both and they both work fine on their own, just not together

29 Oct 2010, 5:04 AM
#283
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Different shipping methods for different categories

If you were to take the calculations that the Table Rate makes for the shipping and add in the total weight of the cart, which is the bagship shipping costs ... wouldn't that give you the total shipping charges ...

You take the count of the bagship and subtract it from the item count used in the Table Rate to compute the shipping costs for the other products ... then add in the weight ...

If there is no weight, then the item count works as it is ...

If there are only bagship then the item count subtracts the item count of the bagship products for 0, then add in the weight for the bagship shipping cost ...

If there is weight and you subtract the item count of the bagship products from the item count you have just the number of items that are not bagship ... then add in the weight ... and you have both ...

Doing it this way, it can all be controlled in one shipping module ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

29 Oct 2010, 3:14 PM
#284
trice avatar

trice

New Zenner

Join Date:
Oct 2010
Posts:
26
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh:

If you were to take the calculations that the Table Rate makes for the shipping and add in the total weight of the cart, which is the bagship shipping costs ... wouldn't that give you the total shipping charges ...

You take the count of the bagship and subtract it from the item count used in the Table Rate to compute the shipping costs for the other products ... then add in the weight ...

If there is no weight, then the item count works as it is ...

If there are only bagship then the item count subtracts the item count of the bagship products for 0, then add in the weight for the bagship shipping cost ...

If there is weight and you subtract the item count of the bagship products from the item count you have just the number of items that are not bagship ... then add in the weight ... and you have both ...

Doing it this way, it can all be controlled in one shipping module ...

ok so I'm really confused. I tried to put them together and it is only working for the reg I'm so so so confused.

<?php
/**
 * @package shippingMethod
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: table2.php 6347 2007-05-20 19:46:59Z ajeh $
 */
/**
 * Enter description here...
 *
 */
class table2 extends base {
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $code;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $title;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $description;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $icon;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $enabled;
  /**
   * Enter description here...
   *
   * @return _2
   */
  function table2() {
    global $order, $db;

    $this->code = 'table2';
    $this->title = MODULE_SHIPPING_TABLE2_TEXT_TITLE;
    $this->description = MODULE_SHIPPING_TABLE2_TEXT_DESCRIPTION;
    $this->sort_order = MODULE_SHIPPING_TABLE2_SORT_ORDER;
    $this->icon = '';
    $this->tax_class = MODULE_SHIPPING_TABLE2_TAX_CLASS;
    $this->tax_basis = MODULE_SHIPPING_TABLE2_TAX_BASIS;
   
    // disable only when entire cart is free shipping 
    if (zen_get_shipping_enabled($this->code)) { 
      $this->enabled = ((MODULE_SHIPPING_TABLE2_STATUS == 'True') ? true : false); 
    } 

      // disable for one master_categories_id
    if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','reg') < 1)) {
      $this->enabled = false;
    while ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','bagship') < 1)) 
      $this->enabled = false;
 }
  
        
    if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE2_ZONE > 0) ) {
      $check_flag = false;
      $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLE2_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
      while (!$check->EOF) {
        if ($check->fields['zone_id'] < 1) {
          $check_flag = true;
          break;
        } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
          $check_flag = true;
          break;
        }
        $check->MoveNext();
      }
 
    
     if (zen_get_shipping_enabled($this->code)) { 
          $this->enabled = ((MODULE_SHIPPING_ITEM_STATUS == 'True') ? true : false); 
     } 

      
      if ($check_flag == false) {
        $this->enabled = false;
      }
    }
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $method
   * @return unknown
   */
  function quote($method = '') {
    global $order, $shipping_weight, $shipping_num_boxes, $total_count;

    // shipping adjustment
    switch (MODULE_SHIPPING_TABLE2_MODE) {
      case ('price'):
        $order_total = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
        break;
      case ('weight'):
        $order_total = $shipping_weight;
        break;
      case ('item'):
        $order_total = $total_count - $_SESSION['cart']->free_shipping_items();
        break;
    }

    $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;

    $table2_cost = split("[:,]" , MODULE_SHIPPING_TABLE2_COST);
    $size = sizeof($table2_cost);
    for ($i=0, $n=$size; $i<$n; $i+=2) {
      if (round($order_total,9) <= $table2_cost[$i]) {
        if (strstr($table2_cost[$i+1], '%')) {
          $shipping = ($table2_cost[$i+1]/100) * $order_total_amount;
        } else {
          $shipping = $table2_cost[$i+1];
        }
        break;
      }
    }

 

    if (MODULE_SHIPPING_TABLE2_MODE == 'weight') {
      $shipping = $shipping * $shipping_num_boxes;
      // show boxes if weight
      switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
        case (0):
        $show_box_weight = '';
        break;
        case (1):
        $show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
        break;
        case (2):
        $show_box_weight = ' (' . number_format($shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')';
        break;
        default:
        $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
        break;
      }
    }

    $this->quotes = array('id' => $this->code,
    'module' => MODULE_SHIPPING_TABLE2_TEXT_TITLE . $show_box_weight,
    'methods' => array(array('id' => $this->code,
    'title' => MODULE_SHIPPING_TABLE2_TEXT_WAY,
    'cost' => $shipping + MODULE_SHIPPING_TABLE2_HANDLING)));

    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;
  }
  /**
   * Enter description here...
   *
   * @return unknown
   */
  function check() {
    global $db;
    if (!isset($this->_check)) {
      $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_TABLE2_STATUS'");
      $this->_check = $check_query->RecordCount();
    }
    return $this->_check;
  }
  /**
   * Enter description here...
   *
   */
  function install() {
    global $db;
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_TABLE2_STATUS', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLE2_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items or count of the items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc<br />You can end the last amount as 10000:7% to charge 7% of the Order Total', '6', '0', 'zen_cfg_textarea(', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Table Method', 'MODULE_SHIPPING_TABLE2_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered or the total number of items orderd.', '6', '0', 'zen_cfg_select_option(array(\'weight\', \'price\', \'item\'), ', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_TABLE2_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_TABLE2_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Tax Basis', 'MODULE_SHIPPING_TABLE2_TAX_BASIS', 'Shipping', 'On what basis is Shipping Tax calculated. Options are<br />Shipping - Based on customers Shipping Address<br />Billing Based on customers Billing address<br />Store - Based on Store address if Billing/Shipping Zone equals Store zone', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\', \'Store\'), ', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_TABLE2_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_TABLE2_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
  }
  /**
   * Enter description here...
   *
   */
  function remove() {
    global $db;
    $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
  }
  /**
   * Enter description here...
   *
   * @return unknown
   */
  function keys() {
    return array('MODULE_SHIPPING_TABLE2_STATUS', 'MODULE_SHIPPING_TABLE2_COST', 'MODULE_SHIPPING_TABLE2_MODE', 'MODULE_SHIPPING_TABLE2_HANDLING', 'MODULE_SHIPPING_TABLE2_TAX_CLASS', 'MODULE_SHIPPING_TABLE2_TAX_BASIS', 'MODULE_SHIPPING_TABLE2_ZONE', 'MODULE_SHIPPING_TABLE2_SORT_ORDER');
  }
}
?>
29 Oct 2010, 4:21 PM
#285
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Different shipping methods for different categories

Remove this code:

      // disable for one master_categories_id
    if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','reg') < 1)) {
      $this->enabled = false;
    while ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','bagship') < 1)) 
      $this->enabled = false;
 }

Add this code down in the function quote:

// bof: remove the bagship item count
global $cart;
$chk_bagship = $_SESSION['cart']->in_cart_check('products_model','bagship');
$order_total = $order_total - $chk_bagship;
// eof: remove the bagship item count

    $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;

On the actual cost change this code:

    $this->quotes = array('id' => $this->code,
    'module' => MODULE_SHIPPING_TABLE2_TEXT_TITLE . $show_box_weight,
    'methods' => array(array('id' => $this->code,
    'title' => MODULE_SHIPPING_TABLE2_TEXT_WAY,
    'cost' => $shipping + MODULE_SHIPPING_TABLE2_HANDLING + ($shipping_weight * 1.00) )));

where the 1.00 is how much you need to charge for the shipping weight * unit cost ...

Now this will calculate the Item Cost based on all items except the bagship and then use the weight that is in the bagship products to add their charge ...

You may need to edit the Table Rate to start with:
0:0.00,your rates here

So that the rate for 0 reg comes out to 0.00 and then the bagship will only be counted ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

29 Oct 2010, 5:58 PM
#286
trice avatar

trice

New Zenner

Join Date:
Oct 2010
Posts:
26
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh:

Remove this code:

  // disable for one master_categories_id
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','reg') < 1)) {
  $this->enabled = false;
while ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','bagship') < 1)) 
  $this->enabled = false;

}

> 
> Add this code down in the function quote:
> ```
// bof: remove the bagship item count
global $cart;
$chk_bagship = $_SESSION['cart']->in_cart_check('products_model','bagship');
$order_total = $order_total - $chk_bagship;
// eof: remove the bagship item count

    $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;

On the actual cost change this code:

$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_TABLE2_TEXT_TITLE . $show_box_weight,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_TABLE2_TEXT_WAY,
'cost' => $shipping + MODULE_SHIPPING_TABLE2_HANDLING + ($shipping_weight * 1.00) )));
> 
> where the 1.00 is how much you need to charge for the shipping weight * unit cost ...
> 
> Now this will calculate the Item Cost based on all items except the bagship and then use the weight that is in the bagship products to add their charge ...
> 
> You may need to edit the Table Rate to start with:
> 0:0.00,your rates here
> 
> So that the rate for 0 reg comes out to 0.00 and then the bagship will only be counted ...

Ok you don't know how much I really really appreciate all your help.  I think I am almost there.  As of right now this is what I get

In shopping cart
1 reg item shipping cost $7
2 reg items shipping cost $8
1 bagship item shipping cost $7
2 bagship items shipping cost $8
1 reg item and 1 baship item shipping cost $8

Somewhere I must have screwed something up because the shipping for bagship is supposed to be 1:8.00, 2:4.00,3:2.00,50:0.00

and the reg shipping is supposed to be 0:0.00,1:4.00,2:5.00,3:6.00,4:7.00,5:8.00,6:9.00,7:10,8:11.00,9:12.00,10:13.00

```php
<?php 
/** 
 * @package shippingMethod 
 * @copyright Copyright 2003-2005 Zen Cart Development Team 
 * @copyright Portions Copyright 2003 osCommerce 
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 
 * @version $Id: table2.php 6347 2007-05-20 19:46:59Z ajeh $ 
 */ 
/** 
 * Enter description here... 
 * 
 */ 
class table2 extends base { 
  /** 
   * Enter description here... 
   * 
   * @var unknown_type 
   */ 
  var $code; 
  /** 
   * Enter description here... 
   * 
   * @var unknown_type 
   */ 
  var $title; 
  /** 
   * Enter description here... 
   * 
   * @var unknown_type 
   */ 
  var $description; 
  /** 
   * Enter description here... 
   * 
   * @var unknown_type 
   */ 
  var $icon; 
  /** 
   * Enter description here... 
   * 
   * @var unknown_type 
   */ 
  var $enabled; 
  /** 
   * Enter description here... 
   * 
   * @return _2 
   */ 
  function table2() { 
    global $order, $db; 

    $this->code = 'table2'; 
    $this->title = MODULE_SHIPPING_TABLE2_TEXT_TITLE; 
    $this->description = MODULE_SHIPPING_TABLE2_TEXT_DESCRIPTION; 
    $this->sort_order = MODULE_SHIPPING_TABLE2_SORT_ORDER; 
    $this->icon = ''; 
    $this->tax_class = MODULE_SHIPPING_TABLE2_TAX_CLASS; 
    $this->tax_basis = MODULE_SHIPPING_TABLE2_TAX_BASIS; 
    
    // disable only when entire cart is free shipping  
    if (zen_get_shipping_enabled($this->code)) {  
      $this->enabled = ((MODULE_SHIPPING_TABLE2_STATUS == 'True') ? true : false);  
    }  

               
    if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE2_ZONE > 0) ) { 
      $check_flag = false; 
      $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLE2_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); 
      while (!$check->EOF) { 
        if ($check->fields['zone_id'] < 1) { 
          $check_flag = true; 
          break; 
        } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) { 
          $check_flag = true; 
          break; 
        } 
        $check->MoveNext(); 
      } 
  
     
     if (zen_get_shipping_enabled($this->code)) {  
          $this->enabled = ((MODULE_SHIPPING_ITEM_STATUS == 'True') ? true : false);  
     }  

       
      if ($check_flag == false) { 
        $this->enabled = false; 
      } 
    } 
  } 
  /** 
   * Enter description here... 
   * 
   * @param unknown_type $method 
   * @return unknown 
   */ 
  function quote($method = '') { 
    global $order, $shipping_weight, $shipping_num_boxes, $total_count; 

   
    // bof: remove the bagship item count
    global $cart;
    $chk_bagship = $_SESSION['cart']->in_cart_check('products_model','bagship');
    $order_total = $order_total - $chk_bagship; 
    // eof: remove the bagship item count

    $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;


   // shipping adjustment 
    switch (MODULE_SHIPPING_TABLE2_MODE) { 
      case ('price'): 
        $order_total = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ; 
        break; 
      case ('weight'): 
        $order_total = $shipping_weight; 
        break; 
      case ('item'): 
        $order_total = $total_count - $_SESSION['cart']->free_shipping_items(); 
        break; 
    } 

    $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ; 

    $table2_cost = split("[:,]" , MODULE_SHIPPING_TABLE2_COST); 
    $size = sizeof($table2_cost); 
    for ($i=0, $n=$size; $i<$n; $i+=2) { 
      if (round($order_total,9) <= $table2_cost[$i]) { 
        if (strstr($table2_cost[$i+1], '%')) { 
          $shipping = ($table2_cost[$i+1]/100) * $order_total_amount; 
        } else { 
          $shipping = $table2_cost[$i+1]; 
        } 
        break; 
      } 
    } 

  

    if (MODULE_SHIPPING_TABLE2_MODE == 'weight') { 
      $shipping = $shipping * $shipping_num_boxes; 
      // show boxes if weight 
      switch (SHIPPING_BOX_WEIGHT_DISPLAY) { 
        case (0): 
        $show_box_weight = ''; 
        break; 
        case (1): 
        $show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')'; 
        break; 
        case (2): 
        $show_box_weight = ' (' . number_format($shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')'; 
        break; 
        default: 
        $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')'; 
        break; 
      } 
    } 

    $this->quotes = array('id' => $this->code, 
    'module' => MODULE_SHIPPING_TABLE2_TEXT_TITLE . $show_box_weight, 
    'methods' => array(array('id' => $this->code, 
    'title' => MODULE_SHIPPING_TABLE2_TEXT_WAY, 
    'cost' => $shipping + MODULE_SHIPPING_TABLE2_HANDLING + ($shipping_weight * 1.00) ))); 

    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; 
  } 
  /** 
   * Enter description here... 
   * 
   * @return unknown 
   */ 
  function check() { 
    global $db; 
    if (!isset($this->_check)) { 
      $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_TABLE2_STATUS'"); 
      $this->_check = $check_query->RecordCount(); 
    } 
    return $this->_check; 
  } 
  /** 
   * Enter description here... 
   * 
   */ 
  function install() { 
    global $db; 
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_TABLE2_STATUS', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())"); 
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLE2_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items or count of the items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc<br />You can end the last amount as 10000:7% to charge 7% of the Order Total', '6', '0', 'zen_cfg_textarea(', now())"); 
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Table Method', 'MODULE_SHIPPING_TABLE2_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered or the total number of items orderd.', '6', '0', 'zen_cfg_select_option(array(\'weight\', \'price\', \'item\'), ', now())"); 
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_TABLE2_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())"); 
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_TABLE2_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())"); 
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Tax Basis', 'MODULE_SHIPPING_TABLE2_TAX_BASIS', 'Shipping', 'On what basis is Shipping Tax calculated. Options are<br />Shipping - Based on customers Shipping Address<br />Billing Based on customers Billing address<br />Store - Based on Store address if Billing/Shipping Zone equals Store zone', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\', \'Store\'), ', now())"); 
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_TABLE2_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())"); 
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_TABLE2_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())"); 
  } 
  /** 
   * Enter description here... 
   * 
   */ 
  function remove() { 
    global $db; 
    $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); 
  } 
  /** 
   * Enter description here... 
   * 
   * @return unknown 
   */ 
  function keys() { 
    return array('MODULE_SHIPPING_TABLE2_STATUS', 'MODULE_SHIPPING_TABLE2_COST', 'MODULE_SHIPPING_TABLE2_MODE', 'MODULE_SHIPPING_TABLE2_HANDLING', 'MODULE_SHIPPING_TABLE2_TAX_CLASS', 'MODULE_SHIPPING_TABLE2_TAX_BASIS', 'MODULE_SHIPPING_TABLE2_ZONE', 'MODULE_SHIPPING_TABLE2_SORT_ORDER'); 
  } 
} 
?> 
29 Oct 2010, 6:39 PM
#287
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Different shipping methods for different categories

How about if you use:

<?php
/**
 * @package shippingMethod
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: table2.php 6347 2007-05-20 19:46:59Z ajeh $
 */
/**
 * Enter description here...
 *
 */
class table2 extends base {
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $code;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $title;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $description;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $icon;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $enabled;
  /**
   * Enter description here...
   *
   * @return _2
   */
  function table2() {
    global $order, $db;

    $this->code = 'table2';
    $this->title = MODULE_SHIPPING_TABLE2_TEXT_TITLE;
    $this->description = MODULE_SHIPPING_TABLE2_TEXT_DESCRIPTION;
    $this->sort_order = MODULE_SHIPPING_TABLE2_SORT_ORDER;
    $this->icon = '';
    $this->tax_class = MODULE_SHIPPING_TABLE2_TAX_CLASS;
    $this->tax_basis = MODULE_SHIPPING_TABLE2_TAX_BASIS;

    // disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
      $this->enabled = ((MODULE_SHIPPING_TABLE2_STATUS == 'True') ? true : false);
    }


    if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE2_ZONE > 0) ) {
      $check_flag = false;
      $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLE2_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
      while (!$check->EOF) {
        if ($check->fields['zone_id'] < 1) {
          $check_flag = true;
          break;
        } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
          $check_flag = true;
          break;
        }
        $check->MoveNext();
      }


     if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_ITEM_STATUS == 'True') ? true : false);
     }


      if ($check_flag == false) {
        $this->enabled = false;
      }
    }
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $method
   * @return unknown
   */
  function quote($method = '') {
    global $order, $shipping_weight, $shipping_num_boxes, $total_count;

   // shipping adjustment
    switch (MODULE_SHIPPING_TABLE2_MODE) {
      case ('price'):
        $order_total = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
        break;
      case ('weight'):
        $order_total = $shipping_weight;
        break;
      case ('item'):
        $order_total = $total_count - $_SESSION['cart']->free_shipping_items();
        break;
    }

    $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;

    // bof: remove the bagship item count
    global $cart;
    $chk_bagship = $_SESSION['cart']->in_cart_check('products_model','bagship');
    $order_total = $order_total - $chk_bagship;
    // eof: remove the bagship item count


    $table2_cost = split("[:,]" , MODULE_SHIPPING_TABLE2_COST);
    $size = sizeof($table2_cost);
    for ($i=0, $n=$size; $i<$n; $i+=2) {
      if (round($order_total,9) <= $table2_cost[$i]) {
        if (strstr($table2_cost[$i+1], '%')) {
          $shipping = ($table2_cost[$i+1]/100) * $order_total_amount;
        } else {
          $shipping = $table2_cost[$i+1];
        }
        break;
      }
    }



    if (MODULE_SHIPPING_TABLE2_MODE == 'weight') {
      $shipping = $shipping * $shipping_num_boxes;
      // show boxes if weight
      switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
        case (0):
        $show_box_weight = '';
        break;
        case (1):
        $show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
        break;
        case (2):
        $show_box_weight = ' (' . number_format($shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')';
        break;
        default:
        $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
        break;
      }
    }

    $this->quotes = array('id' => $this->code,
    'module' => MODULE_SHIPPING_TABLE2_TEXT_TITLE . $show_box_weight,
    'methods' => array(array('id' => $this->code,
    'title' => MODULE_SHIPPING_TABLE2_TEXT_WAY,
    'cost' => $shipping + MODULE_SHIPPING_TABLE2_HANDLING + ($shipping_weight * 1.00) )));

    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;
  }
  /**
   * Enter description here...
   *
   * @return unknown
   */
  function check() {
    global $db;
    if (!isset($this->_check)) {
      $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_TABLE2_STATUS'");
      $this->_check = $check_query->RecordCount();
    }
    return $this->_check;
  }
  /**
   * Enter description here...
   *
   */
  function install() {
    global $db;
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_TABLE2_STATUS', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLE2_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items or count of the items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc<br />You can end the last amount as 10000:7% to charge 7% of the Order Total', '6', '0', 'zen_cfg_textarea(', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Table Method', 'MODULE_SHIPPING_TABLE2_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered or the total number of items orderd.', '6', '0', 'zen_cfg_select_option(array(\'weight\', \'price\', \'item\'), ', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_TABLE2_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_TABLE2_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Tax Basis', 'MODULE_SHIPPING_TABLE2_TAX_BASIS', 'Shipping', 'On what basis is Shipping Tax calculated. Options are<br />Shipping - Based on customers Shipping Address<br />Billing Based on customers Billing address<br />Store - Based on Store address if Billing/Shipping Zone equals Store zone', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\', \'Store\'), ', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_TABLE2_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_TABLE2_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
  }
  /**
   * Enter description here...
   *
   */
  function remove() {
    global $db;
    $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
  }
  /**
   * Enter description here...
   *
   * @return unknown
   */
  function keys() {
    return array('MODULE_SHIPPING_TABLE2_STATUS', 'MODULE_SHIPPING_TABLE2_COST', 'MODULE_SHIPPING_TABLE2_MODE', 'MODULE_SHIPPING_TABLE2_HANDLING', 'MODULE_SHIPPING_TABLE2_TAX_CLASS', 'MODULE_SHIPPING_TABLE2_TAX_BASIS', 'MODULE_SHIPPING_TABLE2_ZONE', 'MODULE_SHIPPING_TABLE2_SORT_ORDER');
  }
}
?>

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

29 Oct 2010, 8:00 PM
#288
trice avatar

trice

New Zenner

Join Date:
Oct 2010
Posts:
26
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh:

How about if you use:

<?php /** * @package shippingMethod * @copyright Copyright 2003-2005 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: table2.php 6347 2007-05-20 19:46:59Z ajeh $ */ /** * Enter description here... * */ class table2 extends base { /** * Enter description here... * * @var unknown_type */ var $code; /** * Enter description here... * * @var unknown_type */ var $title; /** * Enter description here... * * @var unknown_type */ var $description; /** * Enter description here... * * @var unknown_type */ var $icon; /** * Enter description here... * * @var unknown_type */ var $enabled; /** * Enter description here... * * @return _2 */ function table2() { global $order, $db; $this->code = 'table2'; $this->title = MODULE_SHIPPING_TABLE2_TEXT_TITLE; $this->description = MODULE_SHIPPING_TABLE2_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_TABLE2_SORT_ORDER; $this->icon = ''; $this->tax_class = MODULE_SHIPPING_TABLE2_TAX_CLASS; $this->tax_basis = MODULE_SHIPPING_TABLE2_TAX_BASIS; // disable only when entire cart is free shipping if (zen_get_shipping_enabled($this->code)) { $this->enabled = ((MODULE_SHIPPING_TABLE2_STATUS == 'True') ? true : false); } if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE2_ZONE > 0) ) { $check_flag = false; $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLE2_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); while (!$check->EOF) { if ($check->fields['zone_id'] < 1) { $check_flag = true; break; } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) { $check_flag = true; break; } $check->MoveNext(); } if (zen_get_shipping_enabled($this->code)) { $this->enabled = ((MODULE_SHIPPING_ITEM_STATUS == 'True') ? true : false); } if ($check_flag == false) { $this->enabled = false; } } } /** * Enter description here... * * @param unknown_type $method * @return unknown */ function quote($method = '') { global $order, $shipping_weight, $shipping_num_boxes, $total_count; // shipping adjustment switch (MODULE_SHIPPING_TABLE2_MODE) { case ('price'): $order_total = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ; break; case ('weight'): $order_total = $shipping_weight; break; case ('item'): $order_total = $total_count - $_SESSION['cart']->free_shipping_items(); break; } $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ; // bof: remove the bagship item count global $cart; $chk_bagship = $_SESSION['cart']->in_cart_check('products_model','bagship'); $order_total = $order_total - $chk_bagship; // eof: remove the bagship item count $table2_cost = split("[:,]" , MODULE_SHIPPING_TABLE2_COST); $size = sizeof($table2_cost); for ($i=0, $n=$size; $i<$n; $i+=2) { if (round($order_total,9) <= $table2_cost[$i]) { if (strstr($table2_cost[$i+1], '%')) { $shipping = ($table2_cost[$i+1]/100) * $order_total_amount; } else { $shipping = $table2_cost[$i+1]; } break; } } if (MODULE_SHIPPING_TABLE2_MODE == 'weight') { $shipping = $shipping * $shipping_num_boxes; // show boxes if weight switch (SHIPPING_BOX_WEIGHT_DISPLAY) { case (0): $show_box_weight = ''; break; case (1): $show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')'; break; case (2): $show_box_weight = ' (' . number_format($shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')'; break; default: $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')'; break; } } $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_TABLE2_TEXT_TITLE . $show_box_weight, 'methods' => array(array('id' => $this->code, 'title' => MODULE_SHIPPING_TABLE2_TEXT_WAY, 'cost' => $shipping + MODULE_SHIPPING_TABLE2_HANDLING + ($shipping_weight * 1.00) ))); 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; } /** * Enter description here... * * @return unknown */ function check() { global $db; if (!isset($this->_check)) { $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_TABLE2_STATUS'"); $this->_check = $check_query->RecordCount(); } return $this->_check; } /** * Enter description here... * */ function install() { global $db; $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_TABLE2_STATUS', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLE2_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items or count of the items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc<br />You can end the last amount as 10000:7% to charge 7% of the Order Total', '6', '0', 'zen_cfg_textarea(', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Table Method', 'MODULE_SHIPPING_TABLE2_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered or the total number of items orderd.', '6', '0', 'zen_cfg_select_option(array(\'weight\', \'price\', \'item\'), ', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_TABLE2_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_TABLE2_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Tax Basis', 'MODULE_SHIPPING_TABLE2_TAX_BASIS', 'Shipping', 'On what basis is Shipping Tax calculated. Options are<br />Shipping - Based on customers Shipping Address<br />Billing Based on customers Billing address<br />Store - Based on Store address if Billing/Shipping Zone equals Store zone', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\', \'Store\'), ', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_TABLE2_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_TABLE2_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())"); } /** * Enter description here... * */ function remove() { global $db; $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } /** * Enter description here... * * @return unknown */ function keys() { return array('MODULE_SHIPPING_TABLE2_STATUS', 'MODULE_SHIPPING_TABLE2_COST', 'MODULE_SHIPPING_TABLE2_MODE', 'MODULE_SHIPPING_TABLE2_HANDLING', 'MODULE_SHIPPING_TABLE2_TAX_CLASS', 'MODULE_SHIPPING_TABLE2_TAX_BASIS', 'MODULE_SHIPPING_TABLE2_ZONE', 'MODULE_SHIPPING_TABLE2_SORT_ORDER'); } } ?>
Oh boy, so I was getting the incorrect amount for reg items.  So I changed from 1 to 0 (in red)

$this->quotes = array('id' => $this->code,
    'module' => MODULE_SHIPPING_TABLE2_TEXT_TITLE . $show_box_weight,
    'methods' => array(array('id' => $this->code,
    'title' => MODULE_SHIPPING_TABLE2_TEXT_WAY,
    'cost' => $shipping + MODULE_SHIPPING_TABLE2_HANDLING + ($shipping_weight * 0.00) )));


Now all the reg items are coming up with the correct shipping amounts, but the bagship items are coming up 0, even when I put an amount in the Shipping weight, now that is what I'm supposed to be doing right?


```php
<?php
/**
 * @package shippingMethod
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: table2.php 6347 2007-05-20 19:46:59Z ajeh $
 */
/**
 * Enter description here...
 *
 */
class table2 extends base {
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $code;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $title;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $description;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $icon;
  /**
   * Enter description here...
   *
   * @var unknown_type
   */
  var $enabled;
  /**
   * Enter description here...
   *
   * @return _2
   */
  function table2() {
    global $order, $db;

    $this->code = 'table2';
    $this->title = MODULE_SHIPPING_TABLE2_TEXT_TITLE;
    $this->description = MODULE_SHIPPING_TABLE2_TEXT_DESCRIPTION;
    $this->sort_order = MODULE_SHIPPING_TABLE2_SORT_ORDER;
    $this->icon = '';
    $this->tax_class = MODULE_SHIPPING_TABLE2_TAX_CLASS;
    $this->tax_basis = MODULE_SHIPPING_TABLE2_TAX_BASIS;

    // disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
      $this->enabled = ((MODULE_SHIPPING_TABLE2_STATUS == 'True') ? true : false);
    }


    if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE2_ZONE > 0) ) {
      $check_flag = false;
      $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLE2_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
      while (!$check->EOF) {
        if ($check->fields['zone_id'] < 1) {
          $check_flag = true;
          break;
        } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
          $check_flag = true;
          break;
        }
        $check->MoveNext();
      }


     if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_ITEM_STATUS == 'True') ? true : false);
     }


      if ($check_flag == false) {
        $this->enabled = false;
      }
    }
  }
  /**
   * Enter description here...
   *
   * @param unknown_type $method
   * @return unknown
   */
  function quote($method = '') {
    global $order, $shipping_weight, $shipping_num_boxes, $total_count;

   // shipping adjustment
    switch (MODULE_SHIPPING_TABLE2_MODE) {
      case ('price'):
        $order_total = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
        break;
      case ('weight'):
        $order_total = $shipping_weight;
        break;
      case ('item'):
        $order_total = $total_count - $_SESSION['cart']->free_shipping_items();
        break;
    }

    $order_total_amount = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;

    // bof: remove the bagship item count
    global $cart;
    $chk_bagship = $_SESSION['cart']->in_cart_check('products_model','bagship');
    $order_total = $order_total - $chk_bagship;
    // eof: remove the bagship item count


    $table2_cost = split("[:,]" , MODULE_SHIPPING_TABLE2_COST);
    $size = sizeof($table2_cost);
    for ($i=0, $n=$size; $i<$n; $i+=2) {
      if (round($order_total,9) <= $table2_cost[$i]) {
        if (strstr($table2_cost[$i+1], '%')) {
          $shipping = ($table2_cost[$i+1]/100) * $order_total_amount;
        } else {
          $shipping = $table2_cost[$i+1];
        }
        break;
      }
    }



    if (MODULE_SHIPPING_TABLE2_MODE == 'weight') {
      $shipping = $shipping * $shipping_num_boxes;
      // show boxes if weight
      switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
        case (0):
        $show_box_weight = '';
        break;
        case (1):
        $show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
        break;
        case (2):
        $show_box_weight = ' (' . number_format($shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')';
        break;
        default:
        $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
        break;
      }
    }

    $this->quotes = array('id' => $this->code,
    'module' => MODULE_SHIPPING_TABLE2_TEXT_TITLE . $show_box_weight,
    'methods' => array(array('id' => $this->code,
    'title' => MODULE_SHIPPING_TABLE2_TEXT_WAY,
    'cost' => $shipping + MODULE_SHIPPING_TABLE2_HANDLING + ($shipping_weight * 0.00) )));

    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;
  }
  /**
   * Enter description here...
   *
   * @return unknown
   */
  function check() {
    global $db;
    if (!isset($this->_check)) {
      $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_TABLE2_STATUS'");
      $this->_check = $check_query->RecordCount();
    }
    return $this->_check;
  }
  /**
   * Enter description here...
   *
   */
  function install() {
    global $db;
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_TABLE2_STATUS', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLE2_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items or count of the items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc<br />You can end the last amount as 10000:7% to charge 7% of the Order Total', '6', '0', 'zen_cfg_textarea(', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Table Method', 'MODULE_SHIPPING_TABLE2_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered or the total number of items orderd.', '6', '0', 'zen_cfg_select_option(array(\'weight\', \'price\', \'item\'), ', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_TABLE2_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_TABLE2_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Tax Basis', 'MODULE_SHIPPING_TABLE2_TAX_BASIS', 'Shipping', 'On what basis is Shipping Tax calculated. Options are<br />Shipping - Based on customers Shipping Address<br />Billing Based on customers Billing address<br />Store - Based on Store address if Billing/Shipping Zone equals Store zone', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\', \'Store\'), ', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_TABLE2_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
    $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_TABLE2_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
  }
  /**
   * Enter description here...
   *
   */
  function remove() {
    global $db;
    $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
  }
  /**
   * Enter description here...
   *
   * @return unknown
   */
  function keys() {
    return array('MODULE_SHIPPING_TABLE2_STATUS', 'MODULE_SHIPPING_TABLE2_COST', 'MODULE_SHIPPING_TABLE2_MODE', 'MODULE_SHIPPING_TABLE2_HANDLING', 'MODULE_SHIPPING_TABLE2_TAX_CLASS', 'MODULE_SHIPPING_TABLE2_TAX_BASIS', 'MODULE_SHIPPING_TABLE2_ZONE', 'MODULE_SHIPPING_TABLE2_SORT_ORDER');
  }
}
?>
29 Oct 2010, 8:32 PM
#289
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Different shipping methods for different categories

The weight holds the charges for the bagship ... if you multiply the weight by 0 you get 0 ...

Change that to 1 ...

If you add 1 bagship to the cart, and it has a weight set, then that will be the shipping charge ...

If you add 1 reg to the cart then you will be charging the table rate ...

If you add 1 bagship and 1 reg to the cart you will charge the Table Rate and the weight ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

29 Oct 2010, 9:19 PM
#290
trice avatar

trice

New Zenner

Join Date:
Oct 2010
Posts:
26
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh:

The weight holds the charges for the bagship ... if you multiply the weight by 0 you get 0 ...

Change that to 1 ...

If you add 1 bagship to the cart, and it has a weight set, then that will be the shipping charge ...

If you add 1 reg to the cart then you will be charging the table rate ...

If you add 1 bagship and 1 reg to the cart you will charge the Table Rate and the weight ...

OMG ok so it is working, you know what I had to do? LOL Adjust the Package Tare Added percentage! That is so so so awesome. The only thing is that the bags are not discounted when you purchase more than one. Is that something that is possible to incorporate into this? So they are 1:8.00,2:4.00,3:2.00 and anything after that will be 0

By the way I think you are awesome! For sticking with me on this and helping me out! Even though I have been tearing my hair out, I really enjoy learning this!

30 Oct 2010, 12:32 AM
#291
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Different shipping methods for different categories

You said the bagship was based on the weight of the Product ...

There isn't any kind of discount built in for that ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

30 Oct 2010, 1:18 AM
#292
trice avatar

trice

New Zenner

Join Date:
Oct 2010
Posts:
26
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh:

You said the bagship was based on the weight of the Product ...

There isn't any kind of discount built in for that ...

Yea that is what I had originally posted, I'm sorry that I confused you and myself. I later made the comment that I was going to do them both relatively the same way and that I had them both working great in a table rate, but just not together. So there is no way around this then. Can the two table rates be combined into one?

30 Oct 2010, 2:16 AM
#293
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Different shipping methods for different categories

The problem is when there is a cart with a combination of the reg and bagship ... then you do not have a solution ...

You are trying to give a discount on the bagship but those are based on the products_weight ...

There isn't a simple way to test the products in the cart and obtain the shipping costs to know the difference ...

Do all the bagship have the same weight or is it different between the different products marked as bagship?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

30 Oct 2010, 3:34 AM
#294
trice avatar

trice

New Zenner

Join Date:
Oct 2010
Posts:
26
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh:

The problem is when there is a cart with a combination of the reg and bagship ... then you do not have a solution ...

You are trying to give a discount on the bagship but those are based on the products_weight ...

There isn't a simple way to test the products in the cart and obtain the shipping costs to know the difference ...

Do all the bagship have the same weight or is it different between the different products marked as bagship?

All the bagship items will ship at 8, but we would like to make the second one ship at 4 and the third ship at 2 and anything thereafter is free

30 Oct 2010, 3:44 AM
#295
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Different shipping methods for different categories

So all bagship have a products_weight of 8 ... correct?

So there could be an additional calculation to see how many bagship are in the cart based on the weight being 8 and adjust the charge ...

$extra_bagship = 0;
switch (true) {
case ($shipping_weight == 8):
  $extra_bagship = 8;
  break;
case ($shipping_weight == 16):
  $extra_bagship = 12;
  break;
case ($shipping_weight == 24):
  $extra_bagship = 14;
  break;
case ($shipping_weight == 32):
  $extra_bagship = 14;
  break;
}
```Then change the line:
'cost' => $shipping + MODULE_SHIPPING_TABLE2_HANDLING + ($shipping_weight * 1.00) )));

to read:
'cost' => $shipping + MODULE_SHIPPING_TABLE2_HANDLING + $extra_bagship )));

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

30 Oct 2010, 4:06 AM
#296
trice avatar

trice

New Zenner

Join Date:
Oct 2010
Posts:
26
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh:

So all bagship have a products_weight of 8 ... correct?

So there could be an additional calculation to see how many bagship are in the cart based on the weight being 8 and adjust the charge ...

$extra_bagship = 0;
switch (true) {
case ($shipping_weight == 8):
$extra_bagship = 8;
break;
case ($shipping_weight == 16):
$extra_bagship = 12;
break;
case ($shipping_weight == 24):
$extra_bagship = 14;
break;
case ($shipping_weight == 32):
$extra_bagship = 14;
break;
}

> ```
    'cost' => $shipping + MODULE_SHIPPING_TABLE2_HANDLING + ($shipping_weight * 1.00) )));

to read:

'cost' => $shipping + MODULE_SHIPPING_TABLE2_HANDLING + $extra_bagship )));

I'm sure that you get this often, but you are AWESOME!!  You have been so much help!  I have been pulling my hair out, I haven't slept in days and I think I lost my kid around here somewhere because my head has been buried in this screen!  Thank you Thank you Thank you!  :clap:
30 Oct 2010, 12:35 PM
#297
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Different shipping methods for different categories

You are most welcome, glad that all of this customization resulted in getting the shipping to work in the manner that you are needing ... remember us as you become rich and famous ... :cool:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

1 Dec 2010, 4:13 PM
#298
cropinstop avatar

cropinstop

New Zenner

Join Date:
Oct 2006
Location:
Surprise Arizona
Posts:
73
Plugin Contributions:
0

Re: Different shipping methods for different categories

Hi
I have a site with multiple dropshippers at different locations with different shipping rates, so I have employed per-category shipping based on weight.

In order to be competitive with my competition, I have developed a very crude modification to the add-on which provides free shipping for all items in a group when the total sales in that group exceed a dollar threshold (say $50). The threshold per group is currently hard-coded into one of the files. I would like to integrate the thresholds into the admin for this shipping method, but I am not a programmer, so it is beyond my skill level.

If anyone else with programming knowledge is interested in this capability, and wishes to help me develop this enhancement, reply to this post, and I will post my mods on-line.

2 Feb 2011, 6:28 PM
#299
everlost avatar

everlost

New Zenner

Join Date:
Aug 2006
Posts:
40
Plugin Contributions:
0

Re: Different shipping methods for different categories

Hi there,

I am wondering if this method of hiding a particular shipping option would work with the Royal Mail module?
I am finding that as the Royal Mail uses size as well as weight to calculate its prices that I am often subsidising the postage for items bought from my shop as although the weight is low enough for the order to be sent as a 'large letter', the size means it should really be priced as a 'packet' which is a higher cost.
At the moment I have changed my settings so that everything must be posted as a packet, but would like to be able to just stop the categories with larger items from being sent as a large letter (as otherwise folks will end up paying more postage than they need).

So basically can I specify that if a basket/order has one or more items from the excluded (bulky) categories that it has to be sent via the 'packet' option, regardless of if there are smaller items in the order too?

Any help you can give would be much appreciated...so thanks in advance for your help.

Cute 'N' Creepy
"May night hold you safe in her velvet embrace"

2 Feb 2011, 6:31 PM
#300
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Different shipping methods for different categories

I have not used the Royal Mail shipping module but you should be able to customize it in a similar manner ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!