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 301 to 320 of 554
6 Feb 2011, 12:00 PM
#301
everlost avatar

everlost

New Zenner

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

Different shipping methods for different categories

Ajeh:

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

Hmm, I've been struggling with this for a while now and can't seem to get it working.
I want to disable and hide the option of large letter shipping for a certain categories as they have items which are too thick to be posted at this rate.

At the moment my item.php reads as follows...

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

So I tried adding this code underneath...

// disable only when entire cart is free shipping
      if (zen_get_shipping_enabled($this->code)) {
       $this->enabled = ((MODULE_SHIPPING_RM1STLARGELETTER_STATUS == 'True') ? true : false);
      }
      // disable for one master_categories_id
      if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('master_categories_id','148') > 0)) {
          // show RM1STLARGELETTER
          $this->enabled = false;
      } else {
          // hide RM1STLARGELETTER
          $this->enabled = true;
       }     

Like you showed for your UPS version...but nothing happened.
I know it that instance you said to put it in the UPS.php, but the rm1stlargeletter.php doesn't have this code in it to change...

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

Sorry to be a pain, but I really want to get this sorted as I can't afford to lose out by undercharging, but equally don't want to put people off by over charging for shipping. I have really tried to understand it, but I know that one of you clever people will probably see what I am doing wrong straight away and hopefully be able to steer me to a solution.
Thanks for any help you can offer.

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

6 Feb 2011, 12:51 PM
#302
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Different shipping methods for different categories

everlost:

Hmm, I've been struggling with this for a while now and can't seem to get it working.
I want to disable and hide the option of large letter shipping for a certain categories as they have items which are too thick to be posted at this rate.

In the code you provided is a line that reads in part:

$_SESSION['cart']->in_cart_check('master_categories_id','148') > 0))

Since you obtained this code from another example you may or may not have changed the master_categories_id number (148)... anyway, 1st thing to do is to ensure this number does actually match the category for where you want the module disabled.

Other than this, the code provided appears ok.

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

6 Feb 2011, 12:59 PM
#303
everlost avatar

everlost

New Zenner

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

Re: Different shipping methods for different categories

RodG:

In the code you provided is a line that reads in part:

$_SESSION['cart']->in_cart_check('master_categories_id','148') > 0))

Since you obtained this code from another example you may or may not have changed the master_categories_id number (148)... anyway, 1st thing to do is to ensure this number does actually match the category for where you want the module disabled.

Other than this, the code provided appears ok.

Cheers
Rod

The id number 148 is indeed the correct one for the category which I want to disable the shipping method for. It is good to know that it the code seems ok, but if I can get it actually working too that will make my day...:wink2:

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

6 Feb 2011, 1:16 PM
#304
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Different shipping methods for different categories

everlost:

I know it that instance you said to put it in the UPS.php, but the rm1stlargeletter.php doesn't have this code in it to change...

This code needs to be placed in the module that you wish to disable. I'm guessing in your case this would be the rm1stlargeletter.php module .... SO, my next question is, if this module doesn't have the code in it to change, then exactly where did you add this code?

Cheers
Rod.

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

6 Feb 2011, 1:23 PM
#305
everlost avatar

everlost

New Zenner

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

Re: Different shipping methods for different categories

I tried putting it in /includes/modules/shipping/item.php following post #9 by Ajeh.
I admit I was desperately trying to make it work by myself but when I realised it didn't work I removed all the modified code and it is back to normal. Any suggestions as where I should stick (no rude suggestions please)...:laugh:

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

6 Feb 2011, 1:42 PM
#306
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Different shipping methods for different categories

everlost:

I tried putting it in /includes/modules/shipping/item.php following post #9 by Ajeh.

That'll work IF you were using the per item shipping module, but as per previous post, the code needs to be placed within the code that you are using.

everlost:

I admit I was desperately trying to make it work by myself but when I realised it didn't work I removed all the modified code and it is back to normal. Any suggestions as where I should stick (no rude suggestions please)...:laugh:

Assuming it is a module called "rm1stlargeletter" that you are using, then the code needs to be placed into the rm1stlargeletter.php code.

This code SHOULD have a $this->enabled variable being set somewhere near the beginning of the code, so you just need to identify where and then place the additional code somewhere after that (similar to the example(s).

Cheers
Rod.

ps. I'm about to call it a night, so unless Ajeh steps in while I'm sleeping you are probably on your own...

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

6 Feb 2011, 2:10 PM
#307
everlost avatar

everlost

New Zenner

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

Re: Different shipping methods for different categories

RodG:

That'll work IF you were using the per item shipping module, but as per previous post, the code needs to be placed within the code that you are using.

Assuming it is a module called "rm1stlargeletter" that you are using, then the code needs to be placed into the rm1stlargeletter.php code.

This code SHOULD have a $this->enabled variable being set somewhere near the beginning of the code, so you just need to identify where and then place the additional code somewhere after that (similar to the example(s).

Cheers
Rod.

ps. I'm about to call it a night, so unless Ajeh steps in while I'm sleeping you are probably on your own...

Ok Rod, well thanks for your help so far.
I checked out the rm1stlargeletter.php and found the $this->enabled and placed the code under it (code I inserted is marked in red).

<?php
/*

GPL released as part of the big_royalmail_v2.2 package

see CREDITS.txt for the contributors and support forum.

*/


  class rm1stlargeletter {
    var $code, $title, $description, $enabled, $num_zones ;


// class constructor
    function rm1stlargeletter() {

      global $order, $total_weight ;

      $this->code = 'rm1stlargeletter';
      $this->title = MODULE_SHIPPING_RM1STLARGELETTER_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_RM1STLARGELETTER_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_SHIPPING_RM1STLARGELETTER_SORT_ORDER;
      $this->icon = (( defined('DIR_WS_ICONS') ? DIR_WS_ICONS : 'images/icons/' ) . 'shipping_ukrm.jpg');
      $this->tax_class = MODULE_SHIPPING_RM1STLARGELETTER_TAX_CLASS;
      $this->enabled = ((MODULE_SHIPPING_RM1STLARGELETTER_STATUS == 'True') ? true : false);

      // disable for one master_categories_id
      if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('master_categories_id','148') > 0)) {
          // show RM1STLARGELETTER
          $this->enabled = false;
      } else {
          // hide RM1STLARGELETTER
          $this->enabled = true;
       }

      // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
      $this->num_zones = 1;

// inspired by Jim Barrington (JollyJim)

      if( isset($order) && MODULE_SHIPPING_RM1STLARGELETTER_HIDE_SHIPPING_ERRORS == 'True' ){

        switch(isset($order->info['subtotal'])){

        case true:
          if( $order->info['subtotal'] < MODULE_SHIPPING_RM1STLARGELETTER_MIN_ORDERVALUE){
              $this->enabled = false;
            return ;
          }else
          if(MODULE_SHIPPING_RM1STLARGELETTER_MAX_ORDERVALUE != -1 && $order->info['subtotal'] > MODULE_SHIPPING_RM1STLARGELETTER_MAX_ORDERVALUE){
              $this->enabled = false;
            return ;
          }

Still not working though...perhaps someone else will come along and give me some more pointers :frusty:

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

6 Feb 2011, 2:25 PM
#308
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

Below this line:

      // disable for one master_categories_id

what happens if you add:

      // disable for one master_categories_id
     global $cart;

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!

6 Feb 2011, 2:33 PM
#309
everlost avatar

everlost

New Zenner

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

Re: Different shipping methods for different categories

Ajeh:

Below this line:

  // disable for one master_categories_id
> 
> what happens if you add:
> ```
      // disable for one master_categories_id
     global $cart;

Nothing happens, it still shows large letter as an option for posting items in that category :-/

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

6 Feb 2011, 8:09 PM
#310
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

Afraid I do not know what the rest of your code is doing based on the small piece that you are showing ...

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!

6 Feb 2011, 8:46 PM
#311
everlost avatar

everlost

New Zenner

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

Re: Different shipping methods for different categories

Ajeh:

Afraid I do not know what the rest of your code is doing based on the small piece that you are showing ...

Here is the whole of the code

<?php
/*

GPL released as part of the big_royalmail_v2.2 package

see CREDITS.txt for the contributors and support forum.

*/


  class rm1stlargeletter {
    var $code, $title, $description, $enabled, $num_zones ;


// class constructor
    function rm1stlargeletter() {

      global $order, $total_weight ;

      $this->code = 'rm1stlargeletter';
      $this->title = MODULE_SHIPPING_RM1STLARGELETTER_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_RM1STLARGELETTER_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_SHIPPING_RM1STLARGELETTER_SORT_ORDER;
      $this->icon = (( defined('DIR_WS_ICONS') ? DIR_WS_ICONS : 'images/icons/' ) . 'shipping_ukrm.jpg');
      $this->tax_class = MODULE_SHIPPING_RM1STLARGELETTER_TAX_CLASS;
      $this->enabled = ((MODULE_SHIPPING_RM1STLARGELETTER_STATUS == 'True') ? true : false);

      // disable for one master_categories_id
      global $cart;
      if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('master_categories_id','148') > 0)) {
          // show RM1STLARGELETTER
          $this->enabled = false;
      } else {
          // hide RM1STLARGELETTER
          $this->enabled = true;
       }


      // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
      $this->num_zones = 1;

// inspired by Jim Barrington (JollyJim)

      if( isset($order) && MODULE_SHIPPING_RM1STLARGELETTER_HIDE_SHIPPING_ERRORS == 'True' ){

        switch(isset($order->info['subtotal'])){

        case true:
          if( $order->info['subtotal'] < MODULE_SHIPPING_RM1STLARGELETTER_MIN_ORDERVALUE){
              $this->enabled = false;
            return ;
          }else
          if(MODULE_SHIPPING_RM1STLARGELETTER_MAX_ORDERVALUE != -1 && $order->info['subtotal'] > MODULE_SHIPPING_RM1STLARGELETTER_MAX_ORDERVALUE){
              $this->enabled = false;
            return ;
          }
        break;

        case false:
          if($order->info['total'] < MODULE_SHIPPING_RM1STLARGELETTER_MIN_ORDERVALUE){
              $this->enabled = false;
              return ;
          }else
          if(MODULE_SHIPPING_RM1STLARGELETTER_MAX_ORDERVALUE != -1 && $order->info['total'] > MODULE_SHIPPING_RM1STLARGELETTER_MAX_ORDERVALUE){
              $this->enabled = false;
              return ;
          }
        break;

        } // end of switch on subtotal


        // check that it is a valid country being shipped to.
        $dest_country = $order->delivery['country']['iso_code_2'];
        $dest_zone = 0;
  
        for ($i=1; $i<=$this->num_zones; $i++) {
          $countries_table = constant('MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COUNTRIES_' . $i);
          $country_zones = preg_split("/,/", preg_replace('/\s*/','',$countries_table) );
          if (in_array($dest_country, $country_zones)) {
            $dest_zone = $i;
            break;
          }
        }

        // ship to country is invalid for this service
        if ($dest_zone == 0) {
              $this->enabled = false;
            return ;
        }else{

        $this->enabled = false;  // enabled set to true if valid shipping weight found

        $zones_cost = constant('MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COST0_' . $dest_zone)
           . ',' . constant('MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COST1_' . $dest_zone)
           . ',' . constant('MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COST2_' . $dest_zone)
           . ',' . constant('MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COST3_' . $dest_zone);

        $zones_table = preg_split("/[:,]/" , preg_replace('/\s*/','',$zones_cost) );

        $size = sizeof($zones_table);
        for ($i=0; $i<$size; $i+=2) {
          if ($total_weight <= $zones_table[$i]) {
            $this->enabled = true;
            break;
          }
        } // end of looping through

        return ;

      } // end of valid country

     } // end of if hide invalid shipping methods is set

    }

// class methods
    function quote($method = '') {
      global $order, $shipping_weight, $shipping_num_boxes, $currency;

      $currencies = new currencies();

      $dest_country = $order->delivery['country']['iso_code_2'];
      $dest_zone = 0;
      $error = false;

      for ($i=1; $i<=$this->num_zones; $i++) {
        $countries_table = constant('MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COUNTRIES_' . $i);
        $country_zones = preg_split("/,/", preg_replace('/\s*/','',$countries_table) );
        if (in_array($dest_country, $country_zones)) {
          $dest_zone = $i;
          break;
        }
      }
	   //12 FEB 04 MBeedell	NO specified country (or *) then use this zone for all shipping rates
      if ($dest_zone == 0) {
		for ($i=1; $i<=$this->num_zones; $i++) {
		  $countries_table = constant('MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COUNTRIES_' . $i);
		  if ($countries_table == '' or $countries_table == '*') {
		    $dest_zone = $i;
		    break;
		  }
		}
	  }
      if ($dest_zone == 0) {
        $error = true;
      } else {
        $shipping = -1;

	   //12 FEB 04 MBeedell	'glue' together the rates from the 10 cost data entry boxes

        $zones_cost = constant('MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COST0_' . $dest_zone)
           . ',' . constant('MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COST1_' . $dest_zone)
           . ',' . constant('MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COST2_' . $dest_zone)
           . ',' . constant('MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COST3_' . $dest_zone);

        $zones_table = preg_split("/[:,]/" , preg_replace('/\s*/', '', $zones_cost) );
        $size = sizeof($zones_table);
        for ($i=0; $i<$size; $i+=2) {
          if ($shipping_weight <= $zones_table[$i]) { 
            $shipping = $zones_table[$i+1];
			//12 Feb 04 MBeedell - correctly format the total weight... if the weight exceeds the max
			//  weight, then it is divided down over a number of separate packages - so the weight could end
			//  up being a long fraction.

            $sw_text = number_format($shipping_weight, 3, $currencies->currencies[DEFAULT_CURRENCY]['decimal_point'], $currencies->currencies[DEFAULT_CURRENCY]['thousands_point']);


            $shipping_method = MODULE_SHIPPING_RM1STLARGELETTER_TEXT_WAY . ' ' . $dest_country . ' : ' . $sw_text . ' ' . MODULE_SHIPPING_RM1STLARGELETTER_TEXT_UNITS;
            $shipping_method = MODULE_SHIPPING_RM1STLARGELETTER_TEXT_WAY . ' : ' . $sw_text . ' ' . MODULE_SHIPPING_RM1STLARGELETTER_TEXT_UNITS;

            if ($shipping_num_boxes > 1) {

               // PC corrected shipping_num_boxes
              $sw_text = number_format($shipping_num_boxes, 0, $currencies->currencies[DEFAULT_CURRENCY]['decimal_point'], $currencies->currencies[DEFAULT_CURRENCY]['thousands_point']);

              $shipping_method = $shipping_method . ' in ' . $sw_text . ' boxes ';

            }
            break;
          }
        }

        if ($shipping == -1) {
/*          $shipping_cost = 0;
          $shipping_method = MODULE_SHIPPING_RM1STLARGELETTER_UNDEFINED_RATE;
          $this->quotes['error'] = MODULE_SHIPPING_RM1STLARGELETTER_UNDEFINED_RATE;
          return $this->quotes ;*/
        } else {
          $shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_RM1STLARGELETTER_ZONES_HANDLING_' . $dest_zone);
        }
      }

      $this->quotes = array('id' => $this->code,
                           'module' => MODULE_SHIPPING_RM1STLARGELETTER_TEXT_TITLE ,
//                             'module' => 'Royal Mail 1<sup>st</sup> class <i style="font-weight: normal">"large letter"</i>' ,
                            'methods' => array(array('id' => $this->code,
                                                     'title' => $shipping_method,
                                                     'cost' => $shipping_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);


        switch(isset($order->info['subtotal'])){

          case true:
            if($order->info['subtotal'] < MODULE_SHIPPING_RM1STLARGELETTER_MIN_ORDERVALUE){
                $this->quotes['error'] = MODULE_SHIPPING_RM1STLARGELETTER_TEXT_UNDERMINTOTAL . number_format(MODULE_SHIPPING_RM1STLARGELETTER_MIN_ORDERVALUE,2)  ;
              return $this->quotes;
            }else
            if(MODULE_SHIPPING_RM1STLARGELETTER_MAX_ORDERVALUE != -1 && $order->info['subtotal'] > MODULE_SHIPPING_RM1STLARGELETTER_MAX_ORDERVALUE){
                $this->quotes['error'] = MODULE_SHIPPING_RM1STLARGELETTER_TEXT_OVERMAXTOTAL . number_format(MODULE_SHIPPING_RM1STLARGELETTER_MAX_ORDERVALUE,2)  ;
              return $this->quotes;
            }
          break;

          case false:
            if($order->info['total'] < MODULE_SHIPPING_RM1STLARGELETTER_MIN_ORDERVALUE){
                $this->quotes['error'] = MODULE_SHIPPING_RM1STLARGELETTER_TEXT_UNDERMINTOTAL . number_format(MODULE_SHIPPING_RM1STLARGELETTER_MIN_ORDERVALUE,2)  ;
              return $this->quotes;
            }else
            if(MODULE_SHIPPING_RM1STLARGELETTER_MAX_ORDERVALUE != -1 && $order->info['total'] > MODULE_SHIPPING_RM1STLARGELETTER_MAX_ORDERVALUE){
                $this->quotes['error'] = MODULE_SHIPPING_RM1STLARGELETTER_TEXT_OVERMAXTOTAL . number_format(MODULE_SHIPPING_RM1STLARGELETTER_MAX_ORDERVALUE,2)  ;
              return $this->quotes;
            }
          break;

        }


      if ($shipping == -1) {
          $this->quotes['error'] = MODULE_SHIPPING_RM1STLARGELETTER_UNDEFINED_RATE;
      }

      if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_RM1STLARGELETTER_INVALID_ZONE;

      return $this->quotes;
    }

    function check() {
    global $db;
      if (!isset($this->_check)) {
        $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_RM1STLARGELETTER_STATUS'");
        $this->_check = $check_query->RecordCount();
      }
      return $this->_check;
    }

    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 this shipping option', 'MODULE_SHIPPING_RM1STLARGELETTER_STATUS', 'True', 'If you need to adjust your shipping rates, you can use this option to disable it in your shop, instead of re-installing', '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 ('Hide Invalid Shipping', 'MODULE_SHIPPING_RM1STLARGELETTER_HIDE_SHIPPING_ERRORS', 'True', 'Hide this shipping service if it is not valid (either due to exceeding the maximum weight or the min & max order values).', '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, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_RM1STLARGELETTER_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, date_added) values ('Sort Order', 'MODULE_SHIPPING_RM1STLARGELETTER_SORT_ORDER', '40', 'Sort order of display.', '6', '0', now())");


      $handling_test = $db->Execute("SELECT configuration_key FROM " . TABLE_CONFIGURATION . " WHERE configuration_key IN ( 'MODULE_SHIPPING_RM1STLARGELETTER_MIN_ORDERVALUE', 'MODULE_SHIPPING_RM1STLARGELETTER_MAX_ORDERVALUE', 'MODULE_SHIPPING_RM1STLARGELETTER_ZONES_HANDLING_1' ) " );

      if(!$handling_test->RecordCount()){

      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Minimum Order Value', 'MODULE_SHIPPING_RM1STLARGELETTER_MIN_ORDERVALUE', '0.00', 'Minimum order value in £ GBP for this shipping option.<br />Set to 0 for no minimum order value.', '6', '0', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Maximum Order Value', 'MODULE_SHIPPING_RM1STLARGELETTER_MAX_ORDERVALUE', '32.00', 'Maximum order value in £ GBP for this shipping option.<br />Set to -1 if there is no Maximum', '6', '0', 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_RM1STLARGELETTER_ZONES_HANDLING_1', '0', 'The amount it costs you to package the items for first class delivery.', '6', '0', now())");

      }


      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Zone 1 Countries', 'MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COUNTRIES_1', 'GB', 'two character ISO country codes for Great Britain and Northern Ireland " . $i . ".', '6', '0', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping rates in GB & Northern Ireland', 'MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COST0_1', '0.1:0.48', 'Correct on 1<sup>st</sup> April 2007, from information published August 2006. <br />Example: 0.1:0.48 means weights less than or equal to 0.1 Kg would cost £0.48.', '6', '0', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('', 'MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COST1_1', '0.25:0.70', 'Rates cont\'d (2):', '6', '0', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('', 'MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COST2_1', '0.5:0.98', 'Rates cont\'d (3):', '6', '0', now())");
      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('', 'MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COST3_1', '0.75:1.42', 'Rates cont\'d (4):', '6', '0', now())");

    }

    function remove() {
    global $db;
      $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "') AND configuration_key NOT IN ( 'MODULE_SHIPPING_RM1STLARGELETTER_MIN_ORDERVALUE', 'MODULE_SHIPPING_RM1STLARGELETTER_MAX_ORDERVALUE', 'MODULE_SHIPPING_RM1STLARGELETTER_ZONES_HANDLING_1' ) ");
      $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COUNTRIES_1'");
    }

    function keys() {
        $keys = array('MODULE_SHIPPING_RM1STLARGELETTER_STATUS', 'MODULE_SHIPPING_RM1STLARGELETTER_HIDE_SHIPPING_ERRORS', 'MODULE_SHIPPING_RM1STLARGELETTER_TAX_CLASS', 'MODULE_SHIPPING_RM1STLARGELETTER_SORT_ORDER', 'MODULE_SHIPPING_RM1STLARGELETTER_MIN_ORDERVALUE', 'MODULE_SHIPPING_RM1STLARGELETTER_MAX_ORDERVALUE');

        $keys[] = 'MODULE_SHIPPING_RM1STLARGELETTER_ZONES_HANDLING_1';
        $keys[] = 'MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COST0_1';
        $keys[] = 'MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COST1_1';
        $keys[] = 'MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COST2_1';
        $keys[] = 'MODULE_SHIPPING_RM1STLARGELETTER_ZONES_COST3_1';

      return $keys;
    }
  }
?>

Hopefully that will make it clearer, sorry I didn't post it earlier.
Thanks for taking a look :thumbsup:

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

7 Feb 2011, 4:43 AM
#312
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

Maybe I am not understanding what you are trying to do, but you set the $this->enabled to false based on your conditions ... but further down in the code you go on to test for the Zone and set it to true without checking to see if it was true before testing the Zone ...

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!

7 Feb 2011, 7:22 AM
#313
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Different shipping methods for different categories

Ajeh:

Maybe I am not understanding what you are trying to do, but you set the $this->enabled to false based on your conditions ... but further down in the code you go on to test for the Zone and set it to true without checking to see if it was true before testing the Zone ...

I concur with this observation. (I also may not be fully understanding what the OP is trying to do .... I've merely stepped in to help solve the coding error as presented). On this basis, a possible fix:

Change:


if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('master_categories_id','148') > 0)) {
// show RM1STLARGELETTER
$this->enabled = false;

by adding a return, eg:


if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('master_categories_id','148') > 0)) {
// show RM1STLARGELETTER
$this->enabled = false; return

Cheers
rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

7 Feb 2011, 11:39 AM
#314
everlost avatar

everlost

New Zenner

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

Re: Different shipping methods for different categories

Ajeh:

Maybe I am not understanding what you are trying to do, but you set the $this->enabled to false based on your conditions ... but further down in the code you go on to test for the Zone and set it to true without checking to see if it was true before testing the Zone ...

I haven't changed any of the rest of the code, it is as it was originally written. I can't 'read' php so had no idea that what was further down might effect the code that you had originally suggested to someone else.
I am just trying to make it so that the system doesn't show this method of shipping or allow it to be a choice when an item from this category is in the shopping basket (regardless of what else might be in there).

RodG - I tried putting in the return as you suggested, but now when I estimate shipping it shows this error message.

Parse error: syntax error, unexpected '}' in /home/tmraven/public_html/zencart/includes/modules/shipping/rm1stlargeletter.php on line 33

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

8 Feb 2011, 12:52 PM
#315
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Different shipping methods for different categories

everlost:

RodG - I tried putting in the return as you suggested, but now when I estimate shipping it shows this error message.

Parse error: syntax error, unexpected '}' in /home/tmraven/public_html/zencart/includes/modules/shipping/rm1stlargeletter.php on line 33

Add a semicolon** ; **after the 'return' (the semicolon signifies the end line in php)

That'll fix the syntax error.

Cheers
rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

8 Feb 2011, 1:06 PM
#316
everlost avatar

everlost

New Zenner

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

Re: Different shipping methods for different categories

RodG:

Add a semicolon** ; **after the 'return' (the semicolon signifies the end line in php)

That'll fix the syntax error.

Cheers
rod

Fantastic! Thanks that works fine now :D
And I see I can just repeat the code but just replace the category number to exclude other categories from using the service, that is my problems for now sorted.

Thanks again for your patience and help, it is much appreciated.
:clap:

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

8 Feb 2011, 2:10 PM
#317
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Different shipping methods for different categories

everlost:

Fantastic! Thanks that works fine now :D

Thats excellent news. :-)

everlost:

And I see I can just repeat the code but just replace the category number to exclude other categories from using the service,

Welcome to the wonderful world of coding (90% of it is little more than copy/paste and adapt) :D

everlost:

Thanks again for your patience and help, it is much appreciated.
:clap:

On behalf of Ajeh and myself... it is our pleasure :-)

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

2 Mar 2011, 7:53 PM
#318
hornsales avatar

hornsales

New Zenner

Join Date:
Nov 2007
Posts:
54
Plugin Contributions:
0

Re: Different shipping methods for different categories

I want to do what the original poster wanted to do. And Ajeh's code from page 1 of this thread worked fine for me. however I want to disable a shipping module when any item that comes from a specific category is in the cart. However that category is a parent category and it has 9 subcategories. SO I want if any product from any of those 9 subcategories is in the cart to disable the shipping module.
Even if there are items from other categories in the cart, if even one item from one of those 9 subcategories is in the cart, the shipping module is disabled

I see I can not just repeat the IF statement 9 times.

But is there a different variable I can use instead of master_category_id So I can specify the parent category and that will include its sub categories

2 Mar 2011, 8:17 PM
#319
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 can customize the code and use:

    // bof: disable for these master_categories_id
    if (IS_ADMIN_FLAG == false) {
      // check master_categories_id add one line per master_categories_id
      $chk_cat = 0;
      $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','10');
      $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','12');
      $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','17');
      if ($chk_cat > 0) {
        $this->enabled = false;
      }
    }
    // eof: disable for these master_categories_id

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!

2 Mar 2011, 8:41 PM
#320
hornsales avatar

hornsales

New Zenner

Join Date:
Nov 2007
Posts:
54
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh:

You can customize the code and use:

// bof: disable for these master_categories_id
if (IS_ADMIN_FLAG == false) {
  // check master_categories_id add one line per master_categories_id
  $chk_cat = 0;
  $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','10');
  $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','12');
  $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','17');
  if ($chk_cat > 0) {
    $this->enabled = false;
  }
}
// eof: disable for these master_categories_id


Thanks Ajeh

I thought that is what I would need to do.  Just was hoping there was a single variable I could use instead that would include subcategories.

I will try this out