Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Different shipping methods for different categories

Different shipping methods for different categories

Views: 107,637

Results 121 to 140 of 554
21 Sep 2009, 12:33 PM
#121
ajeh avatar

ajeh

Oba-san

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

Different shipping methods for different categories

webpdq:

It does NOT work but maybe someone can show me how to fix it.
// disable when products_model is not all books this goes in item
global $db;
if (($total_count - $_SESSION['cart']->count_contents('products_model','book') == 0)) {
// show
$this->enabled = true;
} else {
// hide
$this->enabled = false;
}

You have an error in your code, you used a single = you need a double == in the IF ...

21 Sep 2009, 12:38 PM
#122
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

Ooba_Scott:

Hi all, i have been trying to implement the code from page 1 into my table rate php file, but with no luck....it just doesnt seem to make any difference

Here is a little bit of info about what i am trying to achieve.....for ease lets say i have 2 categories, each with x amount of products in.

Category 1 is chairs, and needs 2 shipping options, 48hr delivery at £15 and 24hr delivery at £30. But if you buy 2 you get it for cost of one delivery rate ( hence why i chose table rate shipping)

Category 2 is stools, and needs 2 shipping options, 48hr delivery at £10 and 24hr delivery at £20. And once again if you buy 2 you get it for cost of one delivery rate

I decided that probably best way would be to duplicate the table shipping rate 3 extra times, and then only show 2 that is needed per category.

Sadly i cant seem to get the code from page one to work correctly ( i did change the category id to be my id, and changed it from ITEM to TABLE)

Where should this code be placed, and does it overwrite any other code?

Any help would be greatly appreciated!!

Thanks in advance

Scott

If should go at the end of the function table, just before the closing } ...

Could you post your code so we can see it?
Could you post your code?

21 Sep 2009, 1:54 PM
#123
webpdq avatar

webpdq

New Zenner

Join Date:
Apr 2009
Posts:
18
Plugin Contributions:
0

Re: Different shipping methods for different categories

In answer to the question as to where to place the code
You need to be customizing the file:
/includes/modules/shipping/filename.php
where filename is the name of the shipping method that you want to hide or show. Note you have to place this code in all the methods that you want to hide and show. In my case, I put it in zones to hide it and item to show it and just swapped the last two statements about true and false.

21 Sep 2009, 5:53 PM
#124
webpdq avatar

webpdq

New Zenner

Join Date:
Apr 2009
Posts:
18
Plugin Contributions:
0

Re: Different shipping methods for different categories

I must still be missing something. Now Zones show up no matter what is in the cart and item shipping never shows up. It should show only item if the whole cart is books and zone other wise. Here's the code for both files. I have checked and model is set to book.
// disable when products_model is not all books this goes in zones
global $db;
if (($total_count - $_SESSION['cart']->count_contents('products_model','book') == 0)) {
// hide
$this->enabled = false;
} else {
// show
$this->enabled = true;
}

// enable when products_model is all books this goes in item
global $db;
if (($total_count - $_SESSION['cart']->count_contents('products_model','book') == 0)) {
// show
$this->enabled = true;
} else {
// hide
$this->enabled = false;
}

:flex:

21 Sep 2009, 7:37 PM
#125
thenax avatar

thenax

New Zenner

Join Date:
Jun 2009
Posts:
67
Plugin Contributions:
0

Re: Different shipping methods for different categories

I need no free shipping for one category only...
I need to add only this code to freeoptions.php?

 if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('master_categories_id','107') > 0)) {
        $this->enabled = false;
      }  

(it doesn't operate!)

thank you very much

22 Sep 2009, 2:39 AM
#126
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

Depends on where you put that in the code ...

22 Sep 2009, 8:02 AM
#127
ooba_scott avatar

ooba_scott

Zen Follower

Join Date:
Jul 2009
Posts:
218
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh - thank you for your reply, much appreciated :)

I was adding the code into the wrong place! oops my bad!

22 Sep 2009, 3:39 PM
#128
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

Thanks for the update that you were able to get the code working after placing it in the right location of the file ... :smile:

22 Sep 2009, 3:42 PM
#129
ooba_scott avatar

ooba_scott

Zen Follower

Join Date:
Jul 2009
Posts:
218
Plugin Contributions:
0

Re: Different shipping methods for different categories

annoyingly, the client has changed their mind and gone with the way i originally suggested haha

At least i will know now for next time, adn will be able to part my new found knowledge with others

22 Sep 2009, 4:27 PM
#130
webpdq avatar

webpdq

New Zenner

Join Date:
Apr 2009
Posts:
18
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh
Any suggestions for my code in #124? I think it will help a lot of people in this thread.
Thanks
Shirley

22 Sep 2009, 8:03 PM
#131
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 think you are using the wrong function ... :eek:

count_contents doesn't make that kind of check ...

Look at the function in the shopping_cart class for:

  function in_cart_check($check_what, $check_value='1') {
23 Sep 2009, 2:37 PM
#132
webpdq avatar

webpdq

New Zenner

Join Date:
Apr 2009
Posts:
18
Plugin Contributions:
0

Re: Different shipping methods for different categories

Thanks for staying with me on this. I am trying, I just really don't have much experience...

Here's what I put in items. I read an old thread of yours and tried to create a variable to count the number of books.

What does the == mean? Is that equal or not equal? At any rate, when I book one book in the cart, item does not show with this code. Arggghhhh.

// disable when products_model is not all books this goes in item
global $db;
$chk_how_manybooks = $_SESSION['cart']->in_cart_check('products_model','book');
if ($total_count - $chk_how_manybooks == 0) {
// show
$this->enabled = true;
} else {
// hide
$this->enabled = false;
}

23 Sep 2009, 5:20 PM
#133
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

In the IF you want == for the evaluation of the values ...

Start with the clean item.php and change this function:

// class constructor
    function item() {
      global $order, $db;

      $this->code = 'item';
      $this->title = MODULE_SHIPPING_ITEM_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_ITEM_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_SHIPPING_ITEM_SORT_ORDER;
      $this->icon = '';
      $this->tax_class = MODULE_SHIPPING_ITEM_TAX_CLASS;
      $this->tax_basis = MODULE_SHIPPING_ITEM_TAX_BASIS;

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

      if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_ITEM_ZONE > 0) ) {
        $check_flag = false;
        $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_ITEM_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 ($check_flag == false) {
          $this->enabled = false;
        }
      }
// disable when products_model is not all books this goes in item
global $db;
if (IS_ADMIN_FLAG == false && ( $_SESSION['cart']->count_contents() - $_SESSION['cart']->in_cart_check('products_model','book') == 0 )) {
// show
$this->enabled = true;
} else {
// hide
$this->enabled = false;
}
    }

Where this is running you need to use the count_content function and test if in the Admin or not so everything works right ... :smile:

25 Sep 2009, 7:54 PM
#134
webpdq avatar

webpdq

New Zenner

Join Date:
Apr 2009
Posts:
18
Plugin Contributions:
0

Re: Different shipping methods for different categories

Finally got it all to work. thanks!!! I put the code you gave me in item.php. I wanted zones to NOT appear when the order was all books so I made a few changes and put a slight variation code as shown below. I had trouble with the brackets but finally got it. So I put this code in zones.php.

// class constructor
function zones() {
global $order, $db;
$this->code = 'zones';
$this->title = MODULE_SHIPPING_ZONES_TEXT_TITLE;
$this->description = MODULE_SHIPPING_ZONES_TEXT_DESCRIPTION;
$this->sort_order = MODULE_SHIPPING_ZONES_SORT_ORDER;
$this->icon = '';
$this->tax_class = MODULE_SHIPPING_ZONES_TAX_CLASS;
$this->tax_basis = MODULE_SHIPPING_ZONES_TAX_BASIS;

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

// disable when products_model is not all books this goes in item
global $db;
if (IS_ADMIN_FLAG == false && ( $_SESSION['cart']->count_contents() - $_SESSION['cart']->in_cart_check('products_model','book') == 0 )) {
// hide
$this->enabled = false;
} else {
// show
$this->enabled = true;
}

  // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
  $this->num_zones = 4;
}
26 Sep 2009, 4:06 AM
#135
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

Be sure to really test that code ... I think you need change:

// disable when products_model is not all books this goes in item
global $db;

to read:

// disable when products_model is not all books this goes in item
global $db, $cart;
26 Sep 2009, 5:46 PM
#136
webpdq avatar

webpdq

New Zenner

Join Date:
Apr 2009
Posts:
18
Plugin Contributions:
0

Re: Different shipping methods for different categories

thanks for the follow up. I did test it and it worked without the additional coding but I added it and tested it and it still works.
Also I realized it should say, this goes in zones... not item.

28 Sep 2009, 1:36 AM
#137
newbie76 avatar

newbie76

Zen Follower

Join Date:
Aug 2009
Posts:
100
Plugin Contributions:
0

Re: Different shipping methods for different categories

Hi, my general shipping is based on zone rate but I am thinking of adding a category that will need to be priced as per item shipping (that's what the dropshipper for that category uses), which code would I need to edit for that?

I am using 1.3.8a

T-I-A!

28 Sep 2009, 3:24 AM
#138
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

What happens when you have an order with a mix of Products that use the two different shipping methods? :unsure:

28 Sep 2009, 4:19 AM
#139
newbie76 avatar

newbie76

Zen Follower

Join Date:
Aug 2009
Posts:
100
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh:

What happens when you have an order with a mix of Products that use the two different shipping methods? :unsure:

I had kinda thought of that but not properly :blush:, not sure what to do for the best tbh, my current supplier has a 6.99 charge for upto 30kg, the supplier for the new section has a max charge of £15 (which would be 11 items weighing a total of just over a kg), I'll have to see if I may be able to figure it into my markup per item (or at least some) but don't think that will be viable.....

.....goes back to the drawing board

20 Oct 2009, 11:42 AM
#140
spid3r1987 avatar

spid3r1987

Zen Follower

Join Date:
Jul 2009
Posts:
497
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh:

What happens when you have an order with a mix of Products that use the two different shipping methods? :unsure:
ajeh, u seem good with this...
i have aerosols i want to sell.
but the carriage for aerosols is alot more
i want to set it so when any order involves aerosols, it changes from flat carriage to "flat carriage - different cost"
so delivery is £6.95
but when an aerosol is added, delivery is now £15...
is this possible :S
????
pleaseee help me :D