Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Can I restrict certain shipping modules for certain products?

Can I restrict certain shipping modules for certain products?

Views: 3,455

Results 1 to 11 of 11
11 Feb 2013, 5:27 PM
#1
gumboot avatar

gumboot

New Zenner

Join Date:
Jan 2008
Location:
Roberts Creek BC, Canada
Posts:
31
Plugin Contributions:
0

Can I restrict certain shipping modules for certain products?

I have been searching the forums for info but to no avail.

I have product categories on my site http://shadoblixfarm.ca
For most of the categories I want the shipping module (canada post) to be available BUT on the PRESERVES category I wish only the pick up at store option to be shown. Is there a way around this?

Cheers for any help and suggestions.

DJ

12 Feb 2013, 3:12 AM
#3
ajeh avatar

ajeh

Oba-san

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

Re: Can I restrict certain shipping modules for certain products?

If I order some Blackberry Jelly and then I also order a bunch of Tea and Spices, do I still need to pick up the order at the store?

From what I see, all Preserves are using master_categories_id 4 ... is this correct?

If so, you could customize your shipping module with the code:

// bof: turn off shipping module when 1 or more Products are in the cart for master_categories_id 4
  if (!IS_ADMIN_FLAG) {
    // check the count of a specific field
    $chk_cat = 0;
    // check how many Products are in the cart for master_categories_id 4
    $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','4');
    // if any are found turn off the shipping module
    if ($chk_cat > 0) {
      $this->enabled = false;
    }
  }
// eof: turn off shipping module when 1 or more Products are in the cart for master_categories_id 4

That code can be added to most any shipping module, just put it below the code similar to:

      // disable only when entire cart is free shipping
      if (zen_get_shipping_enabled($this->code)) {
        $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
      }
12 Feb 2013, 5:16 AM
#4
gumboot avatar

gumboot

New Zenner

Join Date:
Jan 2008
Location:
Roberts Creek BC, Canada
Posts:
31
Plugin Contributions:
0

Re: Can I restrict certain shipping modules for certain products?

Thanks Ajeh, we will have it stated in the preserves category that they can be ordered online but can only be picked up at the store.

Would there be a way of setting things that works like this ---> if a customer orders preserves and spices and teas, when they proceed to checkout they are informed that (because of the preserves), they will have to pick up their entire order at the store?

Your suggested coding above will work just fine if they ONLY order preserves though.

12 Feb 2013, 2:41 PM
#5
ajeh avatar

ajeh

Oba-san

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

Re: Can I restrict certain shipping modules for certain products?

What shipping methods do you have installed?

If you add the code that I gave you to the shipping module(s) that you are using (except Store Pickup) and make an order of Tea and Preserves, do you see on the checkout_shipping the text:

This is currently the only shipping method available to use on this order.

with just the Store Pickup as the shipping method?

12 Feb 2013, 6:14 PM
#6
gumboot avatar

gumboot

New Zenner

Join Date:
Jan 2008
Location:
Roberts Creek BC, Canada
Posts:
31
Plugin Contributions:
0

Re: Can I restrict certain shipping modules for certain products?

Ajeh,

Currently I have Canada post shipping and pick up at store installed. When I added the above coding to the shipping module and did a test purchase of just preserves, I was still given the option of pick up at store AND canada post shipping. Unless I had installed the coding in the wrong place..... /includes/modules/shipping/item.php

12 Feb 2013, 6:19 PM
#7
ajeh avatar

ajeh

Oba-san

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

Re: Can I restrict certain shipping modules for certain products?

You should place it below:

      // disable only when entire cart is free shipping
      if (zen_get_shipping_enabled($this->code)) {
        $this->enabled = ((MODULE_SHIPPING_ITEM_STATUS == 'True') ? true : false);
      }
12 Feb 2013, 6:20 PM
#8
gumboot avatar

gumboot

New Zenner

Join Date:
Jan 2008
Location:
Roberts Creek BC, Canada
Posts:
31
Plugin Contributions:
0

Re: Can I restrict certain shipping modules for certain products?

Ajeh..... just realized it should have been in the canada post shipping module..... so I added the coding there but when I go to checkout with 2 preserves all I get is a blank screen... is the coding in the wrong place in this instance

12 Feb 2013, 6:57 PM
#9
ajeh avatar

ajeh

Oba-san

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

Re: Can I restrict certain shipping modules for certain products?

Either there is an issue with the new code, or you have white space such as a space(s) or blank line(s) before the starting <?php **tag or the ending **?> in the file ...

Peek in your debug logs in either the /cache or /log directory depending on version of software and see what the error message reads ...

13 Feb 2013, 4:22 AM
#10
gumboot avatar

gumboot

New Zenner

Join Date:
Jan 2008
Location:
Roberts Creek BC, Canada
Posts:
31
Plugin Contributions:
0

Re: Can I restrict certain shipping modules for certain products?

Thanks Ajeh.... working great now..... I had deleted one part of the coding by mistake.

Cheers, Thanks for your help

13 Feb 2013, 4:26 AM
#11
ajeh avatar

ajeh

Oba-san

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

Re: Can I restrict certain shipping modules for certain products?

Thanks for the update that this is now working for you ...