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 21 to 40 of 554
18 Apr 2008, 3:38 PM
#21
ajeh avatar

ajeh

Oba-san

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

Different shipping methods for different categories

GraniteMan44:

I would like to do what the original poster asked. If I want to use "per item" on more than one category, do I have to duplicate the

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

for each category?

Or can I list the others within the same line as the '17' ?

example: 'master_categories_id','17','18', '20')

Thank you.

G

You would use the same concepts of the original post, but you need to change the testing method to look at which master_categories_id values are in the cart ...

A little more expanded definition on this would help ...

Are you needing if the cart contains products from ONLY these categories vs the cart contains products from any of these categories ...

18 Apr 2008, 4:24 PM
#22
chadderuski avatar

chadderuski

Totally Zenned

Join Date:
Apr 2006
Location:
Dark Side of the Moon
Posts:
986
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh,

Wouldn't it be better to use product types to define shipping requirements for say truck only shipping?

I ask that not knowing much about using product types, or even how to customize them. But this seems more appropriate than using a category.

In this case, your only testing for a product type, not many categories. And what happens when you change or move a category? You back in the code fixing things.

This is a big issue with our shop. Most stuff ships UPS, but all the furniture is FREIGHT only, as well as all glass.

18 Apr 2008, 4:50 PM
#23
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 your case, you could make a Product Type and write the dozen files for this ... :eek:

Or you could just add 1 field to the products table and add the code for adding/editing that field in the Admin and then use that as your test for this "truck" only ...

This is a lot faster than a whole product type, however, you do have to remember to update your code on upgrades for this field ...

Or if not many products are like this ... you can cheat and manually enter the data for this field in phpMyAdmin or run a command in the Tool ... Insert SQL Patches such as a new field called: products_ship_by_truck

UPDATE products SET products_ship_by_truck = 1 where products_id = ##;

The other question is ... if 1 product is "truck only" then does the whole order go on the truck? :cool:

21 Apr 2008, 9:46 PM
#24
cwsites avatar

cwsites

New Zenner

Join Date:
Apr 2008
Location:
Georgia
Posts:
15
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh:

What happens when 1 product is in 15 and 3 products are in other categories?

If then you still do not want UPS, then you can block UPS when the whole cart is not categories_id 15 ...

If you need 1 product to be from 15 to allow UPS you can do that too ...

But you need to further define which way you want this to go ...♠

There are about 10 different products in the category 15. I want all of them to use UPS shipping only.

All other main categories and products in the site I want them to block UPS

20 May 2008, 10:10 PM
#25
cwsites avatar

cwsites

New Zenner

Join Date:
Apr 2008
Location:
Georgia
Posts:
15
Plugin Contributions:
0

Re: Different shipping methods for different categories

bump - please answer

20 May 2008, 10:23 PM
#26
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

Imagine for a moment ...

I buy 3 Products from categories_id 15 and that means UPS ...

Tommy buys 4 Products from categories_id 32 and that means "other shipping module(s)" ...

Freddy buys 2 Products from categories_id 32 and 1 Product from categories_id 15 ...

1 Can Tommy use UPS as an option? ... meaning other shipping modules show "and" UPS also shows ... OR, other shipping module(s) show but UPS does NOT show ...

2 Can Freddy "only" use UPS? ... meaning no other shipping modules show

3 Can I "only" use UPS? ... meaning my whole order is categories_id 15 so that is my "only" shipping module to choose from

What "other" shipping module(s) are you using aside from UPS?♠

20 May 2008, 10:44 PM
#27
cwsites avatar

cwsites

New Zenner

Join Date:
Apr 2008
Location:
Georgia
Posts:
15
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh:

Imagine for a moment ...

I buy 3 Products from categories_id 15 and that means UPS ...

Tommy buys 4 Products from categories_id 32 and that means "other shipping module(s)" ...

Freddy buys 2 Products from categories_id 32 and 1 Product from categories_id 15 ...

1 Can Tommy use UPS as an option? ... meaning other shipping modules show "and" UPS also shows ... OR, other shipping module(s) show but UPS does NOT show ...

2 Can Freddy "only" use UPS? ... meaning no other shipping modules show

3 Can I "only" use UPS? ... meaning my whole order is categories_id 15 so that is my "only" shipping module to choose from

What "other" shipping module(s) are you using aside from UPS?♠

Hey, the Category 15 is only for UPS affiliates, so they should only be buying stuff from it. Other than that, if they have at least one product from 15 then they can use UPS and all other methods.

The other methods that we use is only the regular usps (I think.) https://www.prowhiteteeth.com if you want to take a look.

21 May 2008, 12:30 AM
#28
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 "assume" that any products_id that is in categories_id 15 uses master_categories_id 15 ...

You can add a filter on the UPS Shipping Module where if 1 or more products_id are using master_categories_id 15 then UPS will show ... otherwise, it will not be active or be hidden from the checkout_shipping ...

You can customize the ups.php code by adding below this code:

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

to read:

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

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

Now, UPS will only show if at least 1 master_categories_id is 15 ...

However, if you want to turn OFF all of the other shipping modules when there is 1 or more products_id in the categories_id 15 with the same type of test, you can alter the logic to make them NOT show ...

21 May 2008, 12:42 AM
#29
cwsites avatar

cwsites

New Zenner

Join Date:
Apr 2008
Location:
Georgia
Posts:
15
Plugin Contributions:
0

Re: Different shipping methods for different categories

in order for this to work, do I need to enable the UPS shipping on the site for this to work?

21 May 2008, 4:02 AM
#30
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

Ajeh:

This would work better and not make the Admin have a fit:

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

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

As I understand this, if I want to force a specific shipping method for one category, I need to add this magic code to *each* of the other shipping modules offered. If I want the storepickup option to always remain an option, I just don't add the code... Is that correct?

Thanks
21 May 2008, 4:21 AM
#31
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 end up with the:
$this->enabled = true
then the shipping module shows ...

If you end up with the
$this->enabled = false
then the shipping module hides ...

You do have to INSTALL and configure all shipping modules as you normally would ...

NOTE: be sure to save a copy of the original code as well as your changed code ... granted, cloning a shipping module avoids having to save a copy so that it does not get overwritten on an upgrade ...

21 May 2008, 4:41 AM
#32
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

Ajeh:

If you end up with the:
$this->enabled = true
then the shipping module shows ...

If you end up with the
$this->enabled = false
then the shipping module hides ...

You do have to INSTALL and configure all shipping modules as you normally would ...

NOTE: be sure to save a copy of the original code as well as your changed code ... granted, cloning a shipping module avoids having to save a copy so that it does not get overwritten on an upgrade ...

Hi Ajeh - Thanks for the quick response - Great service around here! :D

When you say that I do have to install and configure... Do I need to re-install and configure for this to take affect? I'm adding a new product line and a new shipping method to an existing store. I've obviously missed a step along the way because my changes seem to have no impact... However, I am just modifying the existing flat.php, for example, and over-writing the old.

21 May 2008, 4:51 AM
#33
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

Test it first by adding ONLY 1 Qualifying Product to the Cart ... does it show?

Next, add ONLY 1 Non-Qualifying Product to the Cart ... does it show?

If it shows in both cases, then you have an error somewhere along the way on the logic ...

NOTE: be careful of the configuration_key constant that you are using ... my example used:
MODULE_SHIPPING_ITEM_STATUS

Flat Rate flat uses:
MODULE_SHIPPING_FLAT_STATUS

21 May 2008, 5:17 AM
#34
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

Yep, I was using the wrong configuration_key constant: MODULE_SHIPPING_ITEM_STATUS instead of FLAT - Thanks for cathcing that, it would have driven me nuts!

Now it is working great and I can begin to modify and fine tune. Thanks Ajeh - You Rock!!

21 May 2008, 5:54 AM
#35
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 ... remember us when you are rich and famous ... :smartalec:

2 Jun 2008, 4:42 PM
#36
cwsites avatar

cwsites

New Zenner

Join Date:
Apr 2008
Location:
Georgia
Posts:
15
Plugin Contributions:
0

Re: Different shipping methods for different categories

I am now having a problem, I think it's related it seems that they had some shipping setup so that for some products it was free, for international it was 19 and some of them it was 6.95... Is it the UPS shipping that is effecting this? Or is it something else, because now everything is shipping for 8.50 regardless of what they were supposed to be.

:oops:

2 Jun 2008, 4:49 PM
#37
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

Look in the Modules ... Shipping ...

What Shipping Modules are installed?

If a Shipping Modules is not being used, be sure it is REMOVED and not just marked Disabled ...

2 Jun 2008, 4:53 PM
#38
cwsites avatar

cwsites

New Zenner

Join Date:
Apr 2008
Location:
Georgia
Posts:
15
Plugin Contributions:
0

Re: Different shipping methods for different categories

flat rate, and table rate... UPS isn't installed.

3 Jun 2008, 2:49 PM
#39
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 are the settings for the Table Rate table and do you have Zones setup on either module?

5 Jun 2008, 10:12 PM
#40
cwsites avatar

cwsites

New Zenner

Join Date:
Apr 2008
Location:
Georgia
Posts:
15
Plugin Contributions:
0

Re: Different shipping methods for different categories

Table Rate

Enable Table Method
True

Shipping Table
25:8.50,50:5.50,10000:0.00

Table Method
weight

Handling Fee
0

Tax Class
--none--

Tax Basis
Shipping

Shipping Zone
--none--

Sort Order
0