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

Different shipping methods for different categories

Views: 107,633

Results 61 to 80 of 554
30 Jun 2008, 5:23 AM
#61
stupidbodo avatar

stupidbodo

New Zenner

Join Date:
Jun 2008
Posts:
2
Plugin Contributions:
0

Different shipping methods for different categories

Ajeh:

All of the Shipping Modules have their code stored in the:
/includes/modules/shipping

directory ...

Each has a similar section of code for the:
$this->enabled

that can be controlled in a similar manner ...

The example posted was for the Item Rate item shipping module ... you want to do this for the Table Rate table shipping module ... see if you can't follow along on the similarities to get this working for you and post back your results ... :cool:

I have tried for table but it doens't seems tideo work. The category that I tried to hide still shows up. :shocking:

30 Jun 2008, 7:00 AM
#62
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: Different shipping methods for different categories

If Shipping Module A is the one that I want activated only under certain circumstances how can I de-activate it under normal circumstances?

30 Jun 2008, 1:03 PM
#63
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: Different shipping methods for different categories

I've been able to make the necessary changes so as to restrict all shipping modules except the one I would like - This is a good thing. There are two items I can't seem to get a handle on:

  1. If Shipping Module A is the one that I want activated only under certain circumstances how can I de-activate it under normal circumstances so that it does not show at all?

  2. Somehow the weights are not adhering to set maximum order weights/prices. Example, in grams: 350:7.00,1000:9.50,2000:13.00,3500:18.00,5000:25.00,8000:36.00

This is being followed by one product that is forcing a certain shipping module. However, if I add something to the cart from another category that is also set to force the same shipping module, the numbers are not being followed and I can't seem to ascertain what is throwing them off. It almost seems as if the quantity of the items is coming into play somehow :wacko: although not in any discernable pattern.

Any thoughts? Thanks!!

FYI - To force a certain shipping module for multiple items I have don't the following which may or may not be correct and may or may not be creating my current issues:

  // disable for one master_categories_id 
  if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('master_categories_id','155') > 0)) { 
      $this->enabled = false; 
  }
  
        // disable for one master_categories_id 
  if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('master_categories_id','167') > 0)) { 
      $this->enabled = false; 
  }
  
              // disable for one master_categories_id 
  if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('master_categories_id','168') > 0)) { 
      $this->enabled = false; 
  }
30 Jun 2008, 5:04 PM
#64
cellmonsters avatar

cellmonsters

New Zenner

Join Date:
Dec 2007
Posts:
18
Plugin Contributions:
0

Re: Different shipping methods for different categories

I believe the problem is that only 2 of your disable master categories are working.

I was testing this out myself and unfortunately, i was not able to use more than 2 of these codes. 1 being $this->enabled = true and the other false.

if i used 2 that were false, it only seemed to work with the last category that had the false rather than both.

At the moment, my work around was using products_model rather than master categories. this way any products that is added into the cart regardless of their category, it will force the correct shipping module. You can specify any model code you'd like for the product, the downside is that most products will have duplicate model types but if you add the correct models in the description than you should be good to go. personally i dont mind double models as long as it brings up the correct shipping since i was not able to use more than 2 of the disable master categoryies code no matter how i put them together.

1 Jul 2008, 4:47 AM
#65
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: Different shipping methods for different categories

cellmonsters:

I believe the problem is that only 2 of your disable master categories are working.

I was testing this out myself and unfortunately, i was not able to use more than 2 of these codes. 1 being $this->enabled = true and the other false.

if i used 2 that were false, it only seemed to work with the last category that had the false rather than both.

Actually multiple disable master categories seems to be working well for me. I've since added another, totaling 5, and have had no problems.

I've also been able to sort out my maximum order weights/prices issue, which wasn't an issue after all but me mis-reading my own settings. :blush:

I still have not been able to ascertain how I can de-activate the forced shipping module under normal circumstances so that it does not show at all.

1 Jul 2008, 10:38 PM
#66
cellmonsters avatar

cellmonsters

New Zenner

Join Date:
Dec 2007
Posts:
18
Plugin Contributions:
0

Re: Different shipping methods for different categories

Hmm.. interesting it does not work for me lol.

I guess i will have to really start troubleshooting better lol. I will give it another try and hope i am lucky on it.

Maybe we can help each other out.. send me an email [email protected]

2 Jul 2008, 5:59 AM
#67
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: Different shipping methods for different categories

cellmonsters:

Maybe we can help each other out.. send me an email [email protected]

It's best to work through issues here in the forum so that others may benefit. I will certainly post a response if I feel I have any potentially valuable insight.

8 Jul 2008, 8:28 PM
#68
oblongata avatar

oblongata

New Zenner

Join Date:
Jan 2008
Posts:
3
Plugin Contributions:
0

Re: Different shipping methods for different categories

I am trying to do as the user at the begining of this thread-

category 65, 66

65 I need PICK UP ONLY
66 I need FLAT RATE ONLY

I tried using the code provided and I just cant seem to get it to work- I do know to edit the
Storepickup.php & flat.php but am needing help on the exact code-
Thanks for any help! :D

13 Jul 2008, 12:24 AM
#69
foxmob avatar

foxmob

New Zenner

Join Date:
Jul 2008
Posts:
14
Plugin Contributions:
0

Re: Different shipping methods for different categories

OMG! Thank you, cellmonsters. This is exactly what I've been trying to do for a week. It seemed like such a simple desire, but I've never felt so inept in my life. great tweak!
:clap:

:smartalec: Now I'm going to get greedy. I want to charge a flat rate for certain product_models and a different flat rate for certain other product_models and still per item shipping on yet another product_model in the same cart.

for example, if there are > 4 of product_model '1' (that's one flat rate), 1 of product_model '2' (that has its own flat rate), and product_model '3' (that is always per item), I want to be able to charge flate rate for product_model '1' + flate rate product_model '2' + per item charge for product_model '3'.

what I've been able to do with your code is enforce ONLY per item as long as there is a product_model '3', but that means people are liable to drop product_model '3' from their order altogether. And there's a similar issue between product_models '1' and '2' but in that case, it's trying to get a different (more complex) flat rate total. :lookaroun

13 Jul 2008, 1:18 PM
#70
foxmob avatar

foxmob

New Zenner

Join Date:
Jul 2008
Posts:
14
Plugin Contributions:
0

Re: Different shipping methods for different categories

forgot to mention that I tried what I thought was a simple procedure of cloning the 'flat rate' module but renaming it and replacing 'FLAT' in all areas with 'FLATTER' (just like the wiki had me do with 'STOREPICKUP') so I would in effect have two independent flat rate modules that I could configure with different product_model restrictions. I was able to follow the module creation guide successfully from the z-c wiki instructions based on the storepickup module, but for some reason, I couldn't repeat that success with the flat rate module.

13 Jul 2008, 1:44 PM
#71
foxmob avatar

foxmob

New Zenner

Join Date:
Jul 2008
Posts:
14
Plugin Contributions:
0

Re: Different shipping methods for different categories

edit: wow. was that silly of me. :oops:

cloning does work just as I thought it would. Ajeh explained it all in like 2003 (I hate vB!). it is simply a matter of replacing 'flat' and 'FLAT' with a new name. dunno what the heck I was doing wrong last week.
:D

13 Jul 2008, 2:37 PM
#72
foxmob avatar

foxmob

New Zenner

Join Date:
Jul 2008
Posts:
14
Plugin Contributions:
0

Re: Different shipping methods for different categories

hmm...I'm stuck at the code/syntax level again. I'm trying to call into action my alternate flat rate ('FLAT2') when two specific criteria are met (1+ items from 'NAV' and 1+ items from 'MP'). if I understand php syntax, I need to use the '+' symbol to combine these two functions, but I'm either way off base here, or I just have no clue where to place the '+'. here's what I thought was most logical: ```
// enable for two product_id NAV + MP
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','NAV') > 4)+(IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','MP') > 0)) {
$this->enabled = true;
}

">I've also tried to copy the entire "if" string from NAV and substitute MP in place of NAV so that there are two "if" strings that both point to *$this->enabled = true;*, but that doesn't seem to affect the cart either.
13 Jul 2008, 8:00 PM
#73
foxmob avatar

foxmob

New Zenner

Join Date:
Jul 2008
Posts:
14
Plugin Contributions:
0

Re: Different shipping methods for different categories

foxmob:

hmm...I'm stuck at the code/syntax level again.

....

// enable for two product_id NAV + MP
if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','NAV') > 4) && (IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','MP') > 0)) {
$this->enabled = true;
}


ok.  I bumbled through it.  the operator/symbol/whatever that you need to join the two restrictions is &&.  I've plugged it into the quoted code.  So if you follow the directions to clone flat rate module, you can create another module that allows you to use flat rate under different triggers.  this is useful for drop shippers since you may want to charge multiple flat rates for products that come from different warehouses, but you don't want to do perunit pricing because it's actually one flat rate from each warehouse.  

FYI: this doesn't hide other options.  so if a person has 1 item in his cart that is model 'NAV', he'll have the perunit, flat rate NAV, and flat rate NAV + MP available even though for just one item, perunit is a better deal.  zen cart identifies which one is best anyway, but iunno.  I would rather show all the options.  I'm rambling so I'll stop now.  cheers.
13 Jul 2008, 8:21 PM
#74
foxmob avatar

foxmob

New Zenner

Join Date:
Jul 2008
Posts:
14
Plugin Contributions:
0

Re: Different shipping methods for different categories

damn. I wish I could edit these posts! :? the latest attempt still doesn't work. i forgot to turn off the new module after installing. it still doesn't kick in when it should though.

19 Sep 2008, 12:01 AM
#75
goofygrrl2 avatar

goofygrrl2

New Zenner

Join Date:
Jun 2007
Location:
Texas
Posts:
41
Plugin Contributions:
0

Re: Different shipping methods for different categories

I have been following this thread awhile now for it seemed so easy but I have not been able to get any of the codes to work for me.
I have 3 shipping options FlatA, FlatB & USPS. I would like for USPS to show up for one category #37 and the 2 Flat Rates to show up for everything else. If one of the "everything else" happens to be purchased with a category #37 item I just want the USPS to show.
Please excuse the un-professional quality of my post, this is my first experience of posting to the forums. Been reading them and getting lots of good information all summer!
If there is any solution to this I would really appreciate the info. Thanks.

19 Sep 2008, 1:45 AM
#76
foxmob avatar

foxmob

New Zenner

Join Date:
Jul 2008
Posts:
14
Plugin Contributions:
0

Re: Different shipping methods for different categories

I think it was mentioned earlier that you get into trouble trying to create multiple rules for product categories/types but restricting by product model is more maleable. I have a few flat rates for items that ship from different warehouses. the conceptually easiest thing to do is clone the original "flat" rate and replace all instances of "flat" with a new name, then create a restriction. also remember to clone the languages file and rename it to match the shipping module. but the restrictions by product model as described above definitely work. and you *can *get pretty complex with them. If you only have 3 different product types/models (A, B, C), then it's not too tough. you end up with 7 possible cart combinations that require 7 different scripts: FlatA, FlatB, FlatC, FlatABC, FlatAB, FlatAC, FlatBC. Just "find and replace" with notepad++ a few times to create the additional scripts and create enable/disable rules. it isn't pretty but it works.

Here's a sample of mine where if NAV is the only product type in the cart, the flat rate is triggered. notice that all other product models are explicitly disabled:

class flat {
    var $code, $title, $description, $icon, $enabled;

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

      $this->code = 'flat';
      $this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_SHIPPING_FLAT_SORT_ORDER;
      $this->icon = '';
      $this->tax_class = MODULE_SHIPPING_FLAT_TAX_CLASS;
      $this->tax_basis = MODULE_SHIPPING_FLAT_TAX_BASIS;

      // disable only when entire cart is free shipping
      if (zen_get_shipping_enabled($this->code)) {
        $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
      }
	  // enable for one product_id NAV
	  if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','NAV') > 0)) {
	    $this->enabled = true;
	  }
	  // disable for one product_id SD
	  if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','SD') > 0)) {
	    $this->enabled = false;
	  }
	  // disable for one product_id TM
	  if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','TM') > 0)) {
	    $this->enabled = false;
	  }
	  // disable for one product_id SRW
	  if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','SRW') > 0)) {
	    $this->enabled = false;
	  }
	   // disable for one product_id MP
	  if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','MP') > 0)) {
	    $this->enabled = false;
	  }

this one is a little more complex. it is triggered when there are two kinds of product models in the cart (NAV and MP):

 class flat2 {
    var $code, $title, $description, $icon, $enabled;

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

      $this->code = 'flat2';
      $this->title = MODULE_SHIPPING_FLAT2_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_FLAT2_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_SHIPPING_FLAT2_SORT_ORDER;
      $this->icon = '';
      $this->tax_class = MODULE_SHIPPING_FLAT2_TAX_CLASS;
      $this->tax_basis = MODULE_SHIPPING_FLAT2_TAX_BASIS;

      // disable only when entire cart is free shipping
      if (zen_get_shipping_enabled($this->code)) {
        $this->enabled = ((MODULE_SHIPPING_FLAT2_STATUS == 'True') ? true : false);
      }
	  // enable for two product_id NAV + MP
	  if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','MP') > 0)&&(IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','NAV') > 0)) {
	    $this->enabled = true;
	  }
	   // disable for one product_id SD
	  if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','SD') > 0)) {
	    $this->enabled = false;
	  }
	  // disable for one product_id TM
	  if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','TM') > 0)) {
	    $this->enabled = false;

	  }
	  // disable for one product_id SRW
	  if ((IS_ADMIN_FLAG == false && $_SESSION['cart']->in_cart_check('products_model','SRW') > 0)) {
	    $this->enabled = false;
	  }

it's the same information that's in the thread already. so if it's not working for you, what kind of errors are you getting? zen cart will tell you if you didn't rename all of the files properly because it will stop loading the shipping modules and throw up an error when it reaches the offending script.

if the scripts all pass the initial zen cart checks, then make sure you have them "installed" but "disabled" (yellow circle).

my examples are are culled from the flat rates, but they apply to any module you want to use. I have similar restrictions on USPS as well. exact same code/values. it's a lot easier just to disallow a shipping option for one or two kinds of models than to account for all possible combinations.
:bigups:

19 Sep 2008, 2:38 PM
#77
goofygrrl2 avatar

goofygrrl2

New Zenner

Join Date:
Jun 2007
Location:
Texas
Posts:
41
Plugin Contributions:
0

Re: Different shipping methods for different categories

Thank you so much for the detailed reply. Seeing your code helped my brain put it all together and it works perfectly! Thank you!!!!!

20 Jan 2009, 2:49 AM
#78
meknownowt avatar

meknownowt

New Zenner

Join Date:
Dec 2007
Posts:
78
Plugin Contributions:
0

Re: Different shipping methods for different categories

Now i know why no one made a free mod for this, they could be going for a year with all the requirements people need.

foxmob

Could that be mixed with other postal mods (I'm UK based so use RM) or is it just flat rate, and would you have to add one for all possible options anyone could purchase.

For example Flat AAACD

Sorry if that sounds dumb but it is late, I'm just unsure how it would work with combined shipping, and it's 2:45 am

Also I was looking at a method for creating another product field, and as I use the product model for google base uploads, and it has more options than I would need, so would it be possible to use a created seperate field to do the same thing.

I'll have to look at this in the morning when I'm not one eye in the bed.

Added it to favourites

20 Jan 2009, 3:06 AM
#79
foxmob avatar

foxmob

New Zenner

Join Date:
Jul 2008
Posts:
14
Plugin Contributions:
0

Re: Different shipping methods for different categories

yes. I'm convinced that this is the long way of going about things, but it's the only one I really have my head around, and it DOES work. You can enable/disable any of the basic shipping mods this way (UPS, USPS, Flat Rate). Something I found very useful was to clone USPS and restrict the cloned mod to only one product type (designated by model number not product type). Then I enabled only media mail for that one. It's great. It only kicks in when the cart is full of the specified product type, and people stop trying to order a boatload of toys and then only pay for media mail. hehe

21 Jan 2009, 2:03 AM
#80
meknownowt avatar

meknownowt

New Zenner

Join Date:
Dec 2007
Posts:
78
Plugin Contributions:
0

Re: Different shipping methods for different categories

So if you can copy each postage method and set each one to a selection of products, (roll on the use of OOP in the mods, which would reduce the size of the postage mods at least.)

So what is really needed by the sounds of this is another mod that will prevent these from showing, or mixing with each other or the cart, and then add together their results, before showing them to the user.

so for example

Supplier A Flat rate fixed to price
Supplier B Postal service +20%
Own Stock C Postal Service + 10% with a limit to move to new more expensive postage method at a set price, and free at a higher price.

Buyer selects five items

2 from A, 1 from B, and 2 From C

Instead of the postal mods showing available postage, they hand their results over to the new mod that then calculates the results of each postage method offered, and displays one price to your buyer through the cart, explaining methods to be used.

It sounds so easy, but if it is then, why is there not a mod to do this? Which makes me think it has to be harder than it sounds.

Any of you coders know what I'm missing?