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,885

Results 441 to 460 of 554
21 Feb 2012, 10:29 PM
#441
ajeh avatar

ajeh

Oba-san

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

Different shipping methods for different categories

You are most welcome ... thanks for the update that you have a good solution now ... :smile:

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!

12 Apr 2012, 2:38 PM
#442
pinksparklegirl avatar

pinksparklegirl

New Zenner

Join Date:
Aug 2011
Location:
UK
Posts:
41
Plugin Contributions:
0

Re: Different shipping methods for different categories

I would like for the **Flat Rate **method to only be available when items with manufacturers id 3 or 4 are in the cart. I know how to make a delivery method unavailable when certain items are in the cart, but not how to make it available only when these certain items are in the cart.

I'm using the manufacturers id's to denote medium sized and large sized furniture. When either of these type of items are in the cart then I would like the Flat Rate shipping method to be displayed along with my standard delivery method (giving the customer a choice of both). If no items with manufacturers id 3 or 4 are in the cart then just the standard delivery method should show.

Can anybody help!?

Thanks in advance,
Sarah :smile:

27 Apr 2012, 8:07 PM
#443
dab avatar

dab

Zenner

Join Date:
Jan 2007
Location:
UK
Posts:
64
Plugin Contributions:
0

Re: Different shipping methods for different categories

I am trying to customise the flat rate shipping module to allow for a lower shipping rate for one particular category (and it's sub cats), in this case category #2.

So that if there is something in the basket from this category (and only this one), then the shipping is £1.95.
And if there is something from any other category, or it's a mixed basket, then the shipping is £2.95.

I have cloned the flat rate module to flat1, and the mods I have done to the standard /includes/modules/shipping/flat.php are:

Flat, £2.95 shipping

  // 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','2');
  if ($chk_cat >= 1) {
      $this->enabled = false;
    }
  }
  // eof: disable for these master_categories_id

Flat1, £1.95 shipping

  // 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','2');
  if ($chk_cat < 1) {
      $this->enabled = false;
    }
  }
  // eof: disable for these master_categories_id

This correctly gives me £1.95 shipping for an item in category#2
It also correctly gives me £2.95 shipping for an item in a category other than #2

But if I have a mixed basket (something from category #2 and something from another cat), it gives me £1.95 - where I want £2.95.

Can somebody please point me in the right direction.

Thanks, Dave

27 Apr 2012, 10:41 PM
#444
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 Flat1, £1.95 shipping is ONLY for when ONLY category 2 is in the cart then try using:

if ($chk_cat < 1 && $_SESSION['cart']->count_contents() == $chk_cat) {

If Flat, £2.95 shipping is for when there are NO category 2 in the cart OR when there ARE category 2 AND other categories in the cart try:

if ($chk_cat >= 1 && $_SESSION['cart']->count_contents() == $chk_cat) {

I think I have that right ... :unsure:

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!

27 Apr 2012, 11:39 PM
#445
dab avatar

dab

Zenner

Join Date:
Jan 2007
Location:
UK
Posts:
64
Plugin Contributions:
0

Re: Different shipping methods for different categories

Hi Ajeh, and thanks for the reply.

I have tried that code, and it's getting closer, but has a couple of issues:

With an item just from category 2, it gives £1.95 (flat1) which is correct.
With an item just from category 1, it gives both £1.95 and £2.95 (flat1 and flat) - but I just want £2.95 only (flat)
With an item both from category 1 and category 2, it also gives both flat1 and flat - but again I just want £2.95 only (flat)

It looks like the flat1 option needs to be removed when there is an item from a category other than 2, but I'm not sure what to change. I am running ZC 1.5 on PHP 5.3.10.

Thanks, Dave

28 Apr 2012, 12:40 AM
#446
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

Could you show the code you have in the:

function flat1() {
// what stuff is here
}

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!

28 Apr 2012, 8:16 AM
#447
dab avatar

dab

Zenner

Join Date:
Jan 2007
Location:
UK
Posts:
64
Plugin Contributions:
0

Re: Different shipping methods for different categories

Hi Ajeh

The code I have is this:

    function flat1() {
      global $order, $db;


      $this->code = 'flat1';
      $this->title = MODULE_SHIPPING_FLAT1_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_FLAT1_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_SHIPPING_FLAT1_SORT_ORDER;
      $this->icon = '';
      $this->tax_class = MODULE_SHIPPING_FLAT1_TAX_CLASS;
      $this->tax_basis = MODULE_SHIPPING_FLAT1_TAX_BASIS;


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


      // 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','2');
        if ($chk_cat < 1 && $_SESSION['cart']->count_contents() == $chk_cat) {
          $this->enabled = false;
        }
      }
      // eof: disable for these master_categories_id


      global $cart;
      if (IS_ADMIN_FLAG == false && $_SESSION['cart']->show_total() >= 50.00) {
          $this->enabled = false;
      }


      if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT1_ZONE > 0) ) {
        $check_flag = false;
        $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_FLAT1_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;
        }
      }
    }

It is pretty much a standard file apart from what I am trying to do, and the flat1 name. There is one of your code tweaks from a few years ago to remove the option if the cart value is over £50, but I have tried taking that out, and it's still the same.

Thanks
Dave

28 Apr 2012, 1:10 PM
#448
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

Change flat1 to be:

if ($chk_cat < 1 || ($chk_cat > 1 && $_SESSION['cart']->count_contents() != $chk_cat)) {

So that if there are no category 2 in the cart or the number of items in category 2 in the cart does not match the total number of items then it will turn off.

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!

28 Apr 2012, 4:31 PM
#449
dab avatar

dab

Zenner

Join Date:
Jan 2007
Location:
UK
Posts:
64
Plugin Contributions:
0

Re: Different shipping methods for different categories

Hi Ajeh

Thank you for your help. I have added that code, and it is very nearly there - it's now just the mixed cart that shows both options.

With an item just from category 2, it gives £1.95 (flat1) which is correct.
With an item just from category 1, it gives £2.95 (flat) which is correct.
With an item both from category 1 and category 2, it gives both flat1 and flat - not £2.95 only (flat)

The code mods I now have are:

flat

      // 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','2');
        if ($chk_cat >= 1 && $_SESSION['cart']->count_contents() == $chk_cat) {
          $this->enabled = false;
        }
      }
      // eof: disable for these master_categories_id

flat1

      // 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','2');
        if ($chk_cat < 1 || ($chk_cat > 1 && $_SESSION['cart']->count_contents() != $chk_cat)) {
          $this->enabled = false;
        }
      }
      // eof: disable for these master_categories_id
28 Apr 2012, 4:36 PM
#450
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

flat1 ...

Try this:

        if ($chk_cat < 1 || ($chk_cat >= 1 && $_SESSION['cart']->count_contents() != $chk_cat)) { 

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!

28 Apr 2012, 5:51 PM
#451
dab avatar

dab

Zenner

Join Date:
Jan 2007
Location:
UK
Posts:
64
Plugin Contributions:
0

Re: Different shipping methods for different categories

Ajeh, that is perfect - thank you so much for your help.

Dave

28 Apr 2012, 6:06 PM
#452
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 this is now working for you ... :smile:

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!

27 May 2012, 6:24 AM
#453
sampler111 avatar

sampler111

New Zenner

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

Re: Different shipping methods for different categories

Hi my name is John and i am useing Zencart for a while now but dont know anyting about PHP or any other web language.
My Problem is when i setup Zencart first i was able to add a weight to a product for chargeing then i tried to setup zones and since that my charge by weight will not work.
Can you please tell me how to make the charge by weight work again.?

Thanks.......John

27 May 2012, 1:49 PM
#454
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 is the weight that you are using?

What are your settings in Configuration ... Shipping/Packaging ...

What are your settings on your Zone Rate zones 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!

30 May 2012, 6:06 PM
#455
painted_hills_nb avatar

painted_hills_nb

New Zenner

Join Date:
Apr 2012
Location:
Fossil, OR
Posts:
35
Plugin Contributions:
0

Re: Different shipping methods for different categories

Hi, I am new to ZenCart, having inherited this project in it's present state - although I have several years of web-design experience and can figure out most coding eventually, PHP is not my forte (I appreciate that one of the contributors to this forum acknowledged coding is about 90-some% cut and paste). Anywho...we are currently using v1.3.9h. I spent all day yesterday reading all 46 pages of this thread, I now have the gist of what needs to happen however, I am not finding the solution to our particular issue.

**Product "87" MUST ship UPS 2nd Day Air or can be picked up in store.

One of two solutions would be ideal:
#1: When Product "87" is in the shopping cart (regardless of what else might be in there) disable Per Unit, 3 Day Select & Ground shipping methods (leaving only 2nd Day Air and Store Pickup enabled). *International orders only ship Per Unit - so Product "87" must be disabled for all International Zones.

OR

#2: If shopping cart contains products in addtion to Product "87", shipment is automatically split shipped and alternate shipping methods are enabled for these items. If this is a huge coding issue, we're okay with option #1.

Shipping Modules Insatalled:

FREE SHIPPING! freeshipper
Per Unit perweightunit
Store Pickup storepickup
United Parcel Service ups **

If this scenario has already been addressed in this thread, I must have missed it. Just send me the link.
Thanks in advance for your assistance. :thumbsup:

Christine
"I believe the most important single thing, beyond discipline and creativity is daring to dare." ~Maya Angelou

30 May 2012, 6:41 PM
#456
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

Painted Hills:

You should take a look at Conor's Ceons Advance Shipping module. Conor now has support for zencart 1.5 and has also added FedEx shipping rates. It's affordable (like $70 US) and incredibly flexible.

The only Con is that is doesn't support Google Checkout (unless he's added that since I've last looked)!

30 May 2012, 6:44 PM
#457
ajeh avatar

ajeh

Oba-san

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

Re: Different shipping methods for different categories

To turn off the Per Unit perweightunit when products_id is in the cart, customize the code in:
/includes/modules/shipping/perweightunit.php

with the code:

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

// bof: turn off if products_id 87 is in the cart
if (!IS_ADMIN_FLAG) {
  $chk_product = 0;
  $chk_product += $_SESSION['cart']->in_cart_check('products_id','87');
  if ($chk_product > 0) {
    $this->enabled = false;
  }
}
// eof: turn off if products_id 87 is in the cart

You can customize UPS with this code in RED:

        $cost = preg_replace('/[^0-9.]/', '',  $cost);
// bof: turn off if products_id 87 is in the cart
echo 'UPS TYPE: ' . $type . ' Title: ' . $this->types[$type] . '<br>';
  $chk_product = 0;
  $chk_product += $_SESSION['cart']->in_cart_check('products_id','87');
  if ($chk_product > 0) {
    if ($type == '2DA') {
        $methods[] = array('id' => $type,
                           'title' => $this->types[$type],
                           'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_UPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_UPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_UPS_HANDLING) );
    } else {
      // skip shipping
    }
  } else {
        $methods[] = array('id' => $type,
                           'title' => $this->types[$type],
                           'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_UPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_UPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_UPS_HANDLING) );
  }
// eof: turn off if products_id 87 is in the cart

      }
      $this->quotes['methods'] = $methods;

to replace the code:

        $methods[] = array('id' => $type,
                           'title' => $this->types[$type],
                           'cost' => ($cost * $shipping_num_boxes) +  (MODULE_SHIPPING_UPS_HANDLING_METHOD == 'Box' ?  MODULE_SHIPPING_UPS_HANDLING * $shipping_num_boxes :  MODULE_SHIPPING_UPS_HANDLING) );

NOTE: the echo line for:

echo 'UPS TYPE: ' . $type . ' Title: ' . $this->types[$type] . '<br>';

can be commented out with:

// echo 'UPS TYPE: ' . $type . ' Title: ' . $this->types[$type] . '<br>';

after you are done testing and sure of the $type that you want to use in this code ...

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 May 2012, 9:51 PM
#458
painted_hills_nb avatar

painted_hills_nb

New Zenner

Join Date:
Apr 2012
Location:
Fossil, OR
Posts:
35
Plugin Contributions:
0

Re: Different shipping methods for different categories

Thank you ever so much for your quick reply, Linda! The code is perfect and all seems well with one exception, how do I identify the $type? Rigth now Store Pick-up is the only shipping method showing.

Christine
"I believe the most important single thing, beyond discipline and creativity is daring to dare." ~Maya Angelou

30 May 2012, 10:44 PM
#459
painted_hills_nb avatar

painted_hills_nb

New Zenner

Join Date:
Apr 2012
Location:
Fossil, OR
Posts:
35
Plugin Contributions:
0

Re: Different shipping methods for different categories

"fix shipping method type to 2DA"

Oh yeah!!! This is me doing my Happy Dance! :jump:
Thank you, oh great goddess of PHP!!! :clap:

Christine
"I believe the most important single thing, beyond discipline and creativity is daring to dare." ~Maya Angelou

30 May 2012, 10:44 PM
#460
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 should see echoed on the screen something like:

UPS TYPE: 1DM Title: Next Day Air Early AM
UPS TYPE: 1DA Title: Next Day Air
UPS TYPE: 1DP Title: Next Day Air Saver
UPS TYPE: 2DA Title: 2nd Day Air
UPS TYPE: 3DS Title: 3 Day Select
UPS TYPE: GND Title: Ground

Look for the $type next to the words:
UPS TYPE:

such as what I have highlighted in RED ...

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!